constant expressions

Dave Hanson drh at cs.Princeton.EDU
Fri Aug 17 22:23:24 AEST 1990


>> char * a;
>> a = 1-1;
 
>the assignment of an integer to a pointer is legal
>iff the integer is a null pointer constant,
>which by sec. 3.2.2.3 must be an integral constant
>expression with the value 0.
>so the 1-1 in the expressions above must
>be computed at compile time to determine legality.
 
Yes, because 3.3.16.1 has it in a constraints section.
So it appears that, where the standard says that the compiler CAN
compute constants at translation time, the standard almost lies.
The compiler MUST compute constants at translation time.
This is unfortunate (because a cross-compiler will become difficult).
(It's not quite a lie because the standard's words don't contradict each
other, only the implications do.  Why say "can" when it means "must"?)
 
-- Norman Diamond    diamond at tkou02.enet.dec.com



More information about the Comp.std.c mailing list