[Bug c++/105997] New: A possible optimization bug

zhonghao at pku dot org.cn gcc-bugzilla@gcc.gnu.org
Thu Jun 16 08:47:30 GMT 2022


            Bug ID: 105997
           Summary: A possible optimization bug
           Product: gcc
           Version: 10.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zhonghao at pku dot org.cn
  Target Milestone: ---

ZynAddSubFX is a musical synthesizer. I find a strange code in this project:


#if defined(__GNUC__) && !defined(__clang__) && !defined(__INTEL_COMPILER)
#pragma GCC push_options
#pragma GCC optimize("O0")

void gcc_10_1_0_is_dumb(const std::vector<std::string> &files,
        const int N,
        char *types,
        rtosc_arg_t *args)
        types[N] = 0;
        for(int i=0; i<N; ++i) {
            args[i].s = files[i].c_str();
            types[i]  = 's';

#if defined(__GNUC__) && !defined(__clang__) && !defined(__INTEL_COMPILER)
#pragma GCC pop_options

I checked its commit, and found a message that complained an optimization bug
in gcc:


"Disable gcc optimizations for a specific function

Due to a gcc opt bug a piece of code was put in a separate function to
prevent gcc from optimizing it. Later versions of gcc inlined the
function and the bug reappeared. So now we explicitly tell gcc to not
optimize it."

Is it real a GCC bug?

More information about the Gcc-bugs mailing list