From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19912 invoked by alias); 10 Jan 2015 15:58:53 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 19855 invoked by uid 48); 10 Jan 2015 15:58:49 -0000 From: "joona.kiiski at iki dot fi" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/64491] warning: loop exit may only be reached after undefined behavior Date: Sat, 10 Jan 2015 15:58:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: minor X-Bugzilla-Who: joona.kiiski at iki dot fi X-Bugzilla-Status: WAITING X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-01/txt/msg00685.txt.bz2 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: 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]; } Compile with CXXFLAGS += -O3 -flto LDFLAGS += $(CXXFLAGS) test: test.o $(CXX) -o $@ test.o $(LDFLAGS) 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