[Info-vax] c 7.3 - Why MAYLOSEDATA3 for long pointer math?
Bill Gunshannon
bill at server3.cs.scranton.edu
Fri Mar 13 08:28:54 EDT 2015
In article <74b5efa6-07e8-4cb7-b044-8eaecae4a7cf at googlegroups.com>,
bcjitu at gmail.com writes:
> On Monday, 21 July 2014 17:46:39 UTC+5:30, 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
>>
>
> Hi,
>
> You may disbale this warning by adding following line while compiling:
>
> /WARNINGS = DISABLE = ("MAYLOSEDATA3") NL:
>
I ought to post this on one of the bulletin boards for the students to
see under the heading "How not to do Software Engineering". The solution
is not to turn off the warnings, it is to fix the problem that is causing
the warning.
bill
--
Bill Gunshannon | de-moc-ra-cy (di mok' ra see) n. Three wolves
billg999 at cs.scranton.edu | and a sheep voting on what's for dinner.
University of Scranton |
Scranton, Pennsylvania | #include <std.disclaimer.h>
More information about the Info-vax
mailing list