Z
zaimoni
I've already calculated that the following are valid and should not
error, as both just end up with the character literal 'A' being their
control expression. The unspecified value of the char* pointing to
the string literal is eliminated during evaluation, so the fact it is
unknowable doesn't matter. ('A' is assumed not be to mapped to NUL.)
[GCC 4.2.1 accepts the first, and inconsistently considers *"A" to be
an invalid control expression.]
#if "A"[0]
#else
#error "A"[0] is false
#endif
#if *"A"
#else
#error *"A"[0] is false
#endif
C99 6.4.4.1 does not clearly state that an integer literal is an
object, so this should be invalid as the requirements of the address-
of operator & are imposed even though neither * nor & are evaluated.
#if *&0
#error *&0 is true
#endif
C99 6.4.5p5 goes into some detail regarding the exact layout of a
string literal, so it is clear that a string literal points to an
object -- at conceptual translation phase 7, three conceptual stages
after preprocessing (conceptual stage 4). Does an implementation have
license to assume said layout during preprocessing? Alternately, is
the following required to be invalid even though **&"A" must be
accepted at compile-time? :
#if **&"A"
#else
#error **&"A" is false
#endif
If an implementation has license to accept the above example, is there
some way to infer that it is actually required to accept the above
example?
error, as both just end up with the character literal 'A' being their
control expression. The unspecified value of the char* pointing to
the string literal is eliminated during evaluation, so the fact it is
unknowable doesn't matter. ('A' is assumed not be to mapped to NUL.)
[GCC 4.2.1 accepts the first, and inconsistently considers *"A" to be
an invalid control expression.]
#if "A"[0]
#else
#error "A"[0] is false
#endif
#if *"A"
#else
#error *"A"[0] is false
#endif
C99 6.4.4.1 does not clearly state that an integer literal is an
object, so this should be invalid as the requirements of the address-
of operator & are imposed even though neither * nor & are evaluated.
#if *&0
#error *&0 is true
#endif
C99 6.4.5p5 goes into some detail regarding the exact layout of a
string literal, so it is clear that a string literal points to an
object -- at conceptual translation phase 7, three conceptual stages
after preprocessing (conceptual stage 4). Does an implementation have
license to assume said layout during preprocessing? Alternately, is
the following required to be invalid even though **&"A" must be
accepted at compile-time? :
#if **&"A"
#else
#error **&"A" is false
#endif
If an implementation has license to accept the above example, is there
some way to infer that it is actually required to accept the above
example?