This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: New testcase



>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."


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]