[Info-vax] c 7.3 - Why MAYLOSEDATA3 for long pointer math?
Alan Fay
alan_fay at btinternet.com
Sat Mar 14 18:25:01 EDT 2015
On Monday, 21 July 2014 13:16:39 UTC+1, John E. Malmberg wrote:
> Hello All,
>
> Can someone explain why the C compiler is generating this warning, and
> how to change the code so that the C compiler is happy with out
> suppressing the warning message?
>
> All it is doing is subtracting two long pointers and putting the result
> in either a unsigned or signed 64 bit value.
>
> LION> cc/point=long/noopt/noobject test64.c
>
> c = b - a;
> .......^
> %CC-W-MAYLOSEDATA3, In this statement, "b-a" has a larger data size than
> int. Assignment can result in data loss.
> at line number 11 in file VMS_ROOT:[ld_tools]test64.c;10
>
> d = b - a;
> .......^
> %CC-W-MAYLOSEDATA3, In this statement, "b-a" has a larger data size than
> int. Assignment can result in data loss.
> at line number 12 in file VMS_ROOT:[ld_tools]test64.c;10
>
>
> LION> type test64.c
> #include <types.h>
>
> unsigned __int64 foo(void) {
>
> char * a = "foo1";
> char * b;
> unsigned __int64 c;
> __int64 d;
>
> b = &a[2];
> c = b - a;
> d = b - a;
>
> return c;
> }
>
> HP C V7.3-020 on OpenVMS IA64 V8.4
> HP C V7.3-010 on OpenVMS Alpha V8.4
>
> Regards,
> -John
> wb8tyw at qsl.network
> Personal Opinion Only
Just out of interest on a 64-bit OS X Yosemite (version 10.10.2) system:
[root at mac ~]# clang++ --version
Apple LLVM version 6.1.0 (clang-602.0.37) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.1.0
Thread model: posix
[root at mac ~]#
size_t n ;
printf("%ld\n", sizeof(n)) ;
is 4 bytes.
Alan Fay
More information about the Info-vax
mailing list