http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57489
Bug ID: 57489 Summary: [4.8 regression]: invalid code generated for conditional in template function Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jhand at austin dot rr.com Created attachment 30235 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30235&action=edit test_parse.cpp In gcc-4.8.0 and gcc-4.8.1-RC-20130527, g++ is generating some invalid code that is causing my test regressions to fail. gcc-4.7.3 and gcc-4.6.3 both generate valid code. Comping with -O2 or higher fails, while -O1 or lower works. Adding -fno-inline allows the test to succeed. Changing test_parser() to a non-template function also allows the test to succeed. This has been tested only on a 64-bit environment on Fedora 16. Here is a more complete description of the test. First, the code to parse the number seems to be working properly. However, a conditional in the test, "if (expected_v != actual_v || expected_i != actual_i)" seems to fail even though expected_v == actual_v and expected_i == actual_i. When the test fails, it generates the following message: bad parse: "9223372036854775807": expected_v=9223372036854775807 actual_v=9223372036854775807 expected_i=19 actual_i=19 The number that is being parsed is equal to 0x7fffffffffffffff, however slightly smaller numbers cause the test to still fail, and some number that is smaller allows the test to succeed. I'm attaching the simple test case that demonstrates the problem. Compile with the following: g++ -O2 -o test_parse test_parse.cpp