[cfe-commits] r91073 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/Sema/return.c

Eli Friedman eli.friedman at gmail.com
Thu Dec 10 19:37:23 PST 2009


On Thu, Dec 10, 2009 at 7:10 PM, Mike Stump <mrs at apple.com> wrote:
> In the long run, if we want, we could analyze the asm code in detail, and improve what we think we know...
>
>>> Also, int foo() { asm("a: jump a"); } doesn't fall off the end.  Essentially, trying to understand what is inside the asm is a dangerous thing.
>>
>> You're right, which is why we should follow gcc's policy of assuming it can fall through!

The given code is technically undefined behavior per gcc docs; asm
blocks are required to flow through.

> It is annoying when
>
> int foo() {
>  asm xor eax, eax
> }
>
> gives a warning.

If that actually works, it's pure luck.   gcc warns because it's dangerous, no?

> Bear in mind, gcc's policy for:
>
> asm int foo() {
>  xor eax, eax
> }
>
> is to _not_ give the warning.

Yes; we should follow gcc's lead here.

-Eli




More information about the cfe-commits mailing list