Re: Break in loop expression-3

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jul 24, 2013 at 2:53 AM, Florian Weimer <fweimer@xxxxxxxxxx> wrote:
> On 07/12/2013 06:16 PM, Ian Lance Taylor wrote:
>
>>>      for(int i = 0;; ({break;}))
>
>
>> But probably you wanted to know whether it is a bug in LLVM or in GCC.
>>   It's a bug in LLVM.  You can't use break in a statement expression to
>> break out of a loop that is not in the statement expression.
>> Statement expressions are their own thing; they don't inherit the
>> surrounding context, except that using a goto statement to a label
>> outside the statement expression is permitted.
>
>
> This is not what's implemented in GCC 4.8.  This code compiles (both as C
> and C++):
>
> int
> f()
> {
>   int x = 1;
>   while (1) {
>     x = ({break; 5;});
>   }
>   return x;
> }
>
> The discrepancy between GCC and Clang is whether the expressions in the for
> statement header are considered nested within the loop.  I'm not sure if
> these aspects of statement expressions can be considered fully fleshed out.

Wow, OK, that surprises me.  I now think that's a bug in GCC, but it
may be hard to change it now.

Ian




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux