ICE from template local overload resolution

Bug #1692525 reported by Josh Kelley
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gcc
Fix Released
Medium
gcc-7 (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

This is reported upstream as https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80856, but as instructed by /usr/share/doc/gcc-7-base/README.Bugs, I'm reporting it here too.

Compiling the attached source file with no flags ("g++-7 EngineReportWriter.cpp") results in an internal compiler error:

EngineReportWriter.cpp: In function ‘T WrapToCycle(T) [with T = int]’:
EngineReportWriter.cpp:2:10: internal compiler error: Segmentation fault
 inline T WrapToCycle(T degrees)
          ^~~~~~~~~~~
0x86f4b4a crash_signal
        ../../src/gcc/toplev.c:337
0x84d576b useless_type_conversion_p(tree_node*, tree_node*)
        ../../src/gcc/gimple-expr.c:85
0x83b4b8f types_compatible_p
        ../../src/gcc/gimple-expr.h:66
0x83b4b8f gimple_check_call_args
        ../../src/gcc/cgraph.c:3733
0x83b4b8f gimple_check_call_matching_types(gimple*, tree_node*, bool)
        ../../src/gcc/cgraph.c:3783
0x83b6304 symbol_table::create_edge(cgraph_node*, cgraph_node*, gcall*, long long, int, bool)
        ../../src/gcc/cgraph.c:864
0x83b6529 cgraph_node::create_edge(cgraph_node*, gcall*, long long, int)
        ../../src/gcc/cgraph.c:900
0x83bbb06 execute
        ../../src/gcc/cgraphbuild.c:337
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.

The bug appears to be triggered by the combination of a template plus local function declarations plus overload resolution. If I move the local scope function declarations to global scope, or if I change the function declarations so that overload resolution isn't necessary, then the bug goes away.

This is on Ubuntu 14.04 x86, running GCC 7.1.0 from the Ubuntu Toolchain Test PPA (https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test).

Previous versions of GCC (including GCC 6.3.0 from the Ubuntu Toolchain Test PPA) are unaffected.

GCC 7.1 on godbolt.org is also reporting errors: https://godbolt.org/g/eAYhqd

Revision history for this message
Josh Kelley (joshkel) wrote :
Matthias Klose (doko)
Changed in gcc-7 (Ubuntu):
status: New → Confirmed
Changed in gcc:
importance: Unknown → Medium
status: Unknown → Confirmed
Changed in gcc:
status: Confirmed → In Progress
Changed in gcc:
status: In Progress → Fix Released
Revision history for this message
Matthias Klose (doko) wrote :

fixed in artful

Changed in gcc-7 (Ubuntu):
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.