[Info-vax] C compiler question
Arne Vajhøj
arne at vajhoej.dk
Sat Jul 27 13:17:06 EDT 2019
On 7/27/2019 12:57 PM, Mark Berryman wrote:
> Something I see all the time when porting unix code is something similar
> to the following:
>
> unsigned int x;
> .
> .
> .
> if (x <= 0) {something}
>
> This, of course, generates a QUESTCOMPARE informational. I'm wondering
> what code the compiler generates in such a case. Does it treat the
> variable as if it had been declared signed or does it do something else?
> Is the compiler's behavior in this case defined by a standard or is it
> left up to the implementation?
>
> Part of what I am wondering is if I can count on the code generated by a
> VMS compiler to function the same as the code generated by a gcc or
> clang compiler.
I believe the behavior is defined.
So that:
unsigned int x;
.
if (x <= 0) {something}
will work like:
unsigned int x;
.
if (x == 0) {something}
and:
unsigned int x;
.
if (x >= 0) {something}
as:
unsigned int x;
.
{something}
Arne
More information about the Info-vax
mailing list