This is the mail archive of the gcc@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]

GCC's statement expression extension


GCC has the "statement expression" extension, where a compound statement
may be enclosed in parentheses and used as part of an expression, ({
... }).

It seems GCC does not restrict gotos in and out of statement expressions,
even where they don't particularly make sense.  For example, the
nonsensical program

	#include <stdio.h>
	int main(void){ printf ("%d\n", ({a:; 0; })); goto a; }

dumps core for me on i686-pc-linux-gnu (after printing 0 many times).

Is there any use for such jumps, or should this extension have a
constraint (in standards terminology) that a program shall not jump into a
statement expression from outside (with a mandatory error)?

Do jumps out of statement expressions work sensibly in GCC either (i.e.,
not crash, but with unspecified semantics relating to what of the
containing expression, except where subject to sequence point rules, has
been evaluated)?

Does GCC define the sequence point semantics of statement
expressions?  (For example, may evaluation of multiple statement
expressions within one containing expression be interleaved, cf the ruling
for DR#087 against the old C standard that function calls do not overlap?)

-- 
Joseph S. Myers
jsm28@cam.ac.uk


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