[Info-vax] problem with 64-bit pointers in C

Joukj joukj at hrem.nano.tudelft.nl
Wed Jan 31 03:36:22 EST 2018


Hi all,

when playing around with  cc/pointer=64  I did run in a weird problem 
(see below). It looks to me to be a bug. Does anybody know a 
"work-around" to avoid the problem


C=compiler used: : HP C V7.3-020 on OpenVMS IA64 V8.4

The C-code:
#include <stdio.h>
typedef unsigned int * png_bytep;
typedef unsigned long long png_uint_32;
main()
{
    png_bytep entry_start, buffer;
    printf( "%d  %d  %d\n" , sizeof( entry_start ) ,
            sizeof( (entry_start - buffer) ) ,
            sizeof( buffer ) );
    entry_start = (png_bytep) 888888888888;
    buffer = (png_bytep) 8888888888888;
    printf( "%lld %lld\n" , entry_start , buffer );
    printf( "%lld\n" , buffer - entry_start );
    printf( "%lld\n" , (png_uint_32) buffer - (png_uint_32) entry_start);
}



Compilation gives The warnings are weird because all the pointers should 
be 64-bit (of of long long tyoe and not int):
$ cc test.c/point=64

            sizeof( (entry_start - buffer) ) ,
....................^
%CC-W-MAYLOSEDATA3, In this statement, "entry_start-buffer" has a larger 
data si
ze than int.  Assignment can result in data loss.
at line number 8 in file $DISK6:[JOUKJ.test]test.c;81

    printf( "%lld\n" , buffer - entry_start );
......................^
%CC-W-MAYLOSEDATA3, In this statement, "buffer-entry_start" has a larger 
data si
ze than int.  Assignment can result in data loss.
at line number 13 in file $DISK6:[JOUKJ.test]test.c;81
$ link test
%ILINK-W-COMPWARN, compilation warnings
         module: TEST
         file: $DISK6:[JOUKJ.test]test.OBJ;795




Running the program results in
$ run test
8  4  8
888888888888 8888888888888
-381018112
8000000000000


Expected would be on the first line  8 8 8  instead of the listed 8 4 8
and the thirdline should read 2000000000000 instead  of -381018112


Looks like the artthmatic - (and + ) on pointers is not resulting in the 
expected 64-bit pointer as it should.


                  Regards
                      Jouk



More information about the Info-vax mailing list