[arch-general] gcc broken - Arch specific, applying optimization incorrectly - may explain unexplained problems
PkmX
pkmx.tw at gmail.com
Tue Mar 13 07:17:47 UTC 2018
Hi,
AFAIK this is the exact case of gcc bugzilla #84607:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84607
As this is an upstream bug this should affect all distributions, maybe
the commenter on Debian is using 7.3.1 so he can't reproduce the
issue?
On Tue, Mar 13, 2018 at 2:36 PM, David C. Rankin
<drankinatty at suddenlinkmail.com> wrote:
> Houston -- we have a problem.
>
> The problem is gcc is mis-applying optimizations, and it seems Arch
> specific. See discussion:
>
> [Why does not execute printf inside function?]
> https://stackoverflow.com/questions/49248787/why-does-not-execute-printf-inside-function/49249533#49249533
>
> The basic issue can be summarized in this short snippet:
>
> #include <stdio.h>
>
> int arr[10];
>
> int func()
> {
> printf ("In func\n");
> return 0;
> }
>
> int main (void)
> {
> if (&arr[func()])
> printf("In main\n");
> return 0;
> }
>
> Compile (with or without optimization) and the output on Archlinux (all
> packages current as of 1hr ago) and you get:
>
> $ ./bin/if2
> In main
>
> That is wrong. `func()` has been completely optimized out of the procedure
> in main(). The assembly generated omits any call to func. (full assembly
> posted as part of the answer on SO)
>
> Debian gcc 7.3 does not exhibit this same behavior. I do not know where to
> start looking to find why this is happening, but it does not take much of a
> stretch to see how this could be the root cause of some of the "unexplained"
> errors I and others have seen in the past few days on Arch.
>
> Let me know if I need to file a bug here. Since it "works on Debian" and not
> here, I suspect the bug should start here and so the default optimization we
> package with can be eliminated.
>
> What say the devs?
>
>
> --
> David C. Rankin, J.D.,P.E.
More information about the arch-general
mailing list