Stephen Hoffman · @HoffmanLabs
100 followers · 292 posts · Server infosec.exchange

gets interesting. Subtle. Sometimes even weird.

The familiar has some wrinkles, as is nicely described here:

noncombatant.org/2023/02/12/in

One detail not mentioned there: some platforms will limit the size of a single data structure to a size smaller than the available virtual address space, which means you can have 64-bit pointers, and a 32-bit size_t and 32-bit ptrdiff_t.

Put differently, there are some implementations where the following is a false statement: "But on a 64-bit machine, size_t must be equivalent to uint64_t, and so it is."

For example, one of the weirder hybrid 32- and 64-bit memory model systems, (which only recently saw C99, and with a C17-ish update underway with the OpenVMS x860-64 port of Clang):

$ cc/ver
VSI C V7.4-002 on OpenVMS Alpha V8.4-2L2
$ cc/point=64=argv x
$ link x
$ run x
sizeof( size_t ) = 4
sizeof( ptrdiff_t ) = 4
sizeof( argv ) = 8
$ type x.c
<stdio.h>
<stddef.h>
<stdlib.h>
main( int ac, char *argv[] ) {
printf("sizeof( size_t ) = %d\n", sizeof( size_t ));
printf("sizeof( ptrdiff_t ) = %d\n", sizeof( ptrdiff_t ));
printf("sizeof( argv ) = %d\n", sizeof( argv ));
exit( EXIT_SUCCESS );
}

#c #portability #size_t #openvms #include

Last updated 3 years ago