This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/64491] warning: loop exit may only be reached after undefined behavior
- From: "joona.kiiski at iki dot fi" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 10 Jan 2015 15:58:46 +0000
- Subject: [Bug c++/64491] warning: loop exit may only be reached after undefined behavior
- Auto-submitted: auto-generated
- References: <bug-64491-4 at http dot gcc dot gnu dot org/bugzilla/>
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