Re: gcc warn unreached else {}

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

 



On 2020-07-09 17:11 +0100, Jonny Grant wrote:
> Due to the const' on the 'int i = 1;' gcc removes all the other branches
> unfortunately.
> (I'd rather not use any special build macro to remove the 'const' just to see
> all the generated redundant assembler.)
> 
> main:
>         push    rbp
>         mov     rbp, rsp
>         mov     DWORD PTR [rbp-4], 1
>         mov     eax, 1
>         pop     rbp
>         ret

Use -O0.

It's nothing to do with that `const`.  With something like -O2 it would be
optimized away even if there is no `const`.  `i` is a local variable and the
compiler can determine that nobody can modify it.
-- 
Xi Ruoyao <xry111@xxxxxxxxxxxxxxxx>
School of Aerospace Science and Technology, Xidian University




[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