https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86307
Bug ID: 86307 Summary: Function template and ?: causes segfault Product: gcc Version: 8.0.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: zhonghao at pku dot org.cn Target Milestone: --- The code is as follow: template<class X> void ook(); typedef int (*tf)(); typedef void (*ookf)(); tf r1; ookf r2, r3; bool r4, r5; bool c1; ookf c2, c3; void a() { // rejected r1 = reinterpret_cast<tf>(ook<int>); r2 = 1 ? ook<int> : 0; r3 = *ook<int>; r4 = 1 || ook<int>; r5 = ook<int> == ook<int>; // crash in codegen c1 = !ook<int>; // crash in sema c2 = 1 ? ook<int> : ook<int>; c3 = (0, ook<int>); } clang++ accepts it, but g++ rejects it: code2.c.cpp:14:12: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator!=' r4 = 1 || ook<int>; ^~~~~~~~ code2.c.cpp:15:16: error: invalid operands of types '<unresolved overloaded function type>' and '<unresolved overloaded function type>' to binary 'operator==' r5 = ook<int> == ook<int>; ~~~~~~~~~^~~~~~~~~~~ code2.c.cpp:22:11: error: no context to resolve type of 'ook<int>' c3 = (0, ook<int>); ^~~~~~~~ The code comes from a clang bug report:https://bugs.llvm.org/show_bug.cgi?id=7863 Eli Friedman believes that it is valid.