Patchwork [DOC] Clarify docs about stmt exprs (PR c/51088)

login
register
mail settings
Submitter Marek Polacek
Date March 28, 2014, 2:38 p.m.
Message ID <20140328143805.GA4275@redhat.com>
Download mbox | patch
Permalink /patch/334713/
State New
Headers show

Comments

Marek Polacek - March 28, 2014, 2:38 p.m.
PR51088 contains some Really Bizzare code.  We should tell users
not to do any shenanigans like that.

Ok for trunk?

2014-03-28  Marek Polacek  <polacek@redhat.com>

	PR c/51088
	* doc/extend.texi (Statement Exprs): Add note about taking
	addresses of labels inside of statement expressions.


	Marek
Joseph S. Myers - March 28, 2014, 2:44 p.m.
On Fri, 28 Mar 2014, Marek Polacek wrote:

> PR51088 contains some Really Bizzare code.  We should tell users
> not to do any shenanigans like that.
> 
> Ok for trunk?

I don't think a doc patch resolves this bug.  The compiler should never 
generate code with an undefined reference to a local label like that; 
either the code should get a compile-time error (that's what I suggest), 
or it should generate output that links but has undefined behavior at 
runtime.

Patch

diff --git gcc/doc/extend.texi gcc/doc/extend.texi
index f9114ab..215d0a2 100644
--- gcc/doc/extend.texi
+++ gcc/doc/extend.texi
@@ -206,6 +206,9 @@  Jumping into a statement expression with @code{goto} or using a
 @code{case} or @code{default} label inside the statement expression is
 not permitted.  Jumping into a statement expression with a computed
 @code{goto} (@pxref{Labels as Values}) has undefined behavior.
+Taking the address of a label declared inside of a statement
+expression from outside of the statement expression has undefined
+behavior.
 Jumping out of a statement expression is permitted, but if the
 statement expression is part of a larger expression then it is
 unspecified which other subexpressions of that expression have been