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

Re: break in statement expression in while condition fails to compile


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


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