gcc broken - Arch specific, applying optimization incorrectly - may explain unexplained problems

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



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.



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux