On 12/10/2013 02:21 PM, Prathamesh Kulkarni wrote:
The following code fails to compile with gcc-4.8.2.
int main(void)
{
while ( ({ break; 0; }) )
;
return 0;
}
foo.c:3:14: error: break statement not within loop or switch
while ( ({ break; 0; }) )
^
Is this a compile-error or is it a bug in GCC ?
clang-3.2 seems to compile it.
I came across a thread on this issue
in context of for loop, but I couldn't get a definite answer.
http://gcc.gnu.org/ml/gcc-help/2013-07/msg00100.html
There's also bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44715>.
I think it's fine to reject such code.
--
Florian Weimer / Red Hat Product Security Team