New testcase
David Korn
dkorn@pixelpower.com
Tue Nov 14 06:59:00 GMT 2000
>The third line contains an expression that is common in glibc's string
>function macros. I'm not actually sure it's valid C (can someone tell
>for certain?) but it would make sense to make it a GNU C extension if
>it isn't.
>int z = (&"Foobar"[1] - &"Foobar"[0]);
Yep, that's thoroughly valid C. "Foobar" is a const char *. Nothing
in the ANSI standard guarantees that the two instances will necessarily
be folded into one, so you can't be certain that z == 1 afterwards, but
there's no reason in the world why you can't take a couple of pointers,
subscript them, take the address of the results and (since they're of the
same type) subtract them.
DaveK
--
The Boulder Pledge: "Under no circumstances will I ever purchase anything
offered to me as the result of an unsolicited email message. Nor will I
forward chain letters, petitions, mass mailings, or virus warnings to large
numbers of others. This is my contribution to the survival of the online
community."
More information about the Gcc-patches
mailing list