I mounted ubuntu/trusty64 vagrant box (https://app.vagrantup.com/ubuntu/boxes/trusty64) and I have the following code:
#include <stdio.h>
int main () {
short count = -1;
int a = 5 ;
int* a_ptr = &a;
char b = 'A';
char* b_ptr = &b;
printf ("count's value = %d \n", count);
printf ("count's address = %p \n", &count);
printf ("a's value = %d \n", a);
printf ("a's address = %p \n", &a);
printf ("a_ptr value = %p \n", a_ptr);
printf ("a_ptr address = %p \n", &a_ptr);
printf ("a_ptr deref'ed= %d \n", *a_ptr);
printf ("\n");
printf ("b's value = %d \n", b);
printf ("b's address = %p \n", &b);
printf ("b_ptr value = %p \n", b_ptr);
printf ("b_ptr address = %p \n", &b_ptr);
printf ("b_ptr deref'ed= %d \n", *b_ptr);
printf ("\n");
for (count = -30; count < 500; count++) {
printf ("test: %3d: %p: (%d, %x)\n", count, b_ptr+count, *(b_ptr+count),*(b_ptr+count)) ;
}
}
which shows the output of:
count's value = -1
count's address = 0x7ffd9440876a
a's value = 5
a's address = 0x7ffd94408764
a_ptr value = 0x7ffd94408764
a_ptr address = 0x7ffd94408758
a_ptr deref'ed= 5
b's value = 65
b's address = 0x7ffd94408757
b_ptr value = 0x7ffd94408757
b_ptr address = 0x7ffd94408748
b_ptr deref'ed= 65
test: -15: 0x7ffd94408748: (87, 57)
test: -14: 0x7ffd94408749: (-121, ffffff87)
test: -13: 0x7ffd9440874a: (64, 40)
test: -12: 0x7ffd9440874b: (-108, ffffff94)
test: -11: 0x7ffd9440874c: (-3, fffffffd)
test: -10: 0x7ffd9440874d: (127, 7f)
I am only showing the content at 0x7ffd94408748 which is 0x7ffd94408757, which is the address of b as expected.
Notice a memory address is spread over 6 memory locations on a supposed 64-bit processor. I tested other data types and it appears that the other data types are also represented with at most 8 bits per memory location, so I conclude that it is a 8-bit machine.
However, when I run $ getconf WORD_BIT, I get 32 and when I run $uname -a, I see "Linux vagrant-ubuntu-trusty-64 3.13.0-170-generic #220-Ubuntu SMP Thu May 9 12:40:49 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux."
In my VirtualBox manager, I see this machine is a 64-bit Ubuntu.
Which is the correct word length of this machine? Is there something about virtualization that makes its true word length appear different that what is stated (i.e. 64 bits)?
I see similar posts at: Determine word size of my processor How to determine whether a given Linux is 32 bit or 64 bit? how to find if the machine is 32bit or 64bit
but trying out the above links shows various results between 32 and 64 bits, so I am confused even more.