[Bug c++/64491] warning: loop exit may only be reached after undefined behavior

joona.kiiski at iki dot fi gcc-bugzilla@gcc.gnu.org
Sat Jan 10 15:58:00 GMT 2015


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64491

joona.kiiski at iki dot fi changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |joona.kiiski at iki dot fi

--- Comment #2 from joona.kiiski at iki dot fi ---
Hi,

My name is Joona Kiiski, I'm one the authors of Stockfish chess software
(https://stockfishchess.org/). This bug was originally reported to us a week
ago. 

After initial analysis it looked obviously like a gcc bug, so we advised the
reporter to raise a bug against GCC. Unfortunately, he wasn't able to give you
nearly enough details. I hope that what I can provide below meets your
expectations:

- Environment: qemu-x86-64 running debian sid
- GCC: Debian snapshot 20141812 5.0

- The bug appears when compiling the Stockfish master branch from
https://github.com/official-stockfish/Stockfish.git with this snapshot.

- For you convenience I've reduced the problem to:

<test.cpp>
int A[8];
int B[8];
int C;

int main() {
    for (int f = 0; f <= 7; ++f)
        A[f] = f;
    for (int f = 0; f <= 7; ++f)
        B[f] = (f > 0 ? A[f - 1] : 0) | (f < 7 ? A[f + 1] : 0);
    C = B[7];
}
</test.cpp>

Compile with

<Makefile>
CXXFLAGS += -O3 -flto
LDFLAGS += $(CXXFLAGS)
test: test.o
    $(CXX) -o $@ test.o $(LDFLAGS)
</Makefile>

Files above are also viewable at
https://github.com/official-stockfish/Stockfis/tree/gcc_bug/src

This produces the bogus warning mentioned in the original bug report.

If you need any further details, please let me know.

Kind Regards,
Joona Kiiski



More information about the Gcc-bugs mailing list