[Date Prev][Date Next][Thread Prev][Thread Next][Author Index][Date Index][Thread Index]

&* in C, you win!

but you were wrong in agreeing with me.

from a posting of Doug Gwyn in comp.std.c
Doug was on the committee

+ Semantic violations are not forced simply by use of expressions
as operands of sizeof, in cases where the expressions would produce
semantic violations if actually executed.  I.e. sizeof(&a[N]), which
expands to sizeof(&*(a+N)) is valid since a+N is a valid pointer,
even though *(a+N) cannot be executed in a strictly conforming
program.  Strange but true: semantically invalid expressions may
occur in strictly conforming programs in some contexts so long as
they are never executed!

Here is his posting & disclaimer
I trust his opinion on this as he knows more about this than I (or he)
want(s) to.