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]
Other format: [Raw text]

Re: Patch for bugs 772 and 17913


On Wed, 30 Mar 2005, Mark Mitchell wrote:

> Yes, I think those are desirable semantics.  Personally, I'd be happy to
> disallow jumps out of statement expressions, but I can't really justify that,
> at least in C.  In C++, destructor semantics may make jumps out of
> statement-expressions more problematic -- but, then again, they may not.

There is also the fact that real code is using jumps out of statement 
expressions - and where the statement expression is the full expression 
this doesn't pose real problems as to what has or has not been evaluated 
at the time of the jump.  (And even without statement expressions you can 
still longjmp or throw an exception from within a subexpression leaving it 
indeterminate which other subexpressions have been evaluated.)

> Given that we're disallowing jumps inward, does it make sense to make all
> labels in statement expressions implicitly local?  I suppose that it might
> still be possible to get the ICE by storing the address of the label in some
> variable, and then using a computed goto later.

Making labels local runs into the problem that when you encounter "goto a" 
or "&&a" inside a statement expression you wouldn't know whether this is 
an outer label a with ordinary function scope (which may or may not have 
been defined at that point) or a label a defined inside the statement 
expression which is local to that statement expression - and so would need 
additional complexity to handle the scope only being determined later.  
(All the complexities involved in the present approach still need to be 
present in the compiler in a very similar form in order to fix bug 12913, 
jumps into scope of declarations with variably modified type not being 
diagnosed, so it's not one complexity replacing another.)  For that reason 
I decided against making labels local although it seemed attractive in the 
original discussion leading to bug 772.

-- 
Joseph S. Myers               http://www.srcf.ucam.org/~jsm28/gcc/
    jsm@polyomino.org.uk (personal mail)
    joseph@codesourcery.com (CodeSourcery mail)
    jsm28@gcc.gnu.org (Bugzilla assignments and CCs)


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