The below code compiles fine with clang but causes this ICE with gcc g++ (GCC) 6.0.0 20151222 (experimental) bug.cpp:5:6: internal compiler error: tree check: accessed elt 2 of tree_vec with 1 elts in tsubst, at cp/pt.c:12851 auto operator|(Option<ValueType, Value>, OptionsRhs) { ^~~~~~~~ 0xf7ac05 tree_vec_elt_check_failed(int, int, char const*, int, char const*) ../../src-fix/gcc/tree.c:9802 0x6aff39 tree_vec_elt_check(tree_node const*, int, char const*, int, char const*) ../../src-fix/gcc/tree.h:3445 0x678dd7 tsubst(tree_node*, tree_node*, int, tree_node*) ../../src-fix/gcc/cp/pt.c:12851 0x66f740 tsubst_copy ../../src-fix/gcc/cp/pt.c:13949 0x674e68 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) ../../src-fix/gcc/cp/pt.c:16088 0x669d88 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../src-fix/gcc/cp/pt.c:15658 0x68ed4a tsubst_template_args ../../src-fix/gcc/cp/pt.c:11108 0x681d9a tsubst_decl ../../src-fix/gcc/cp/pt.c:11607 0x678807 tsubst(tree_node*, tree_node*, int, tree_node*) ../../src-fix/gcc/cp/pt.c:12695 0x66fd7e tsubst_copy ../../src-fix/gcc/cp/pt.c:13865 0x674e68 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) ../../src-fix/gcc/cp/pt.c:16088 0x67547b tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool, bool) ../../src-fix/gcc/cp/pt.c:16326 0x669d88 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../src-fix/gcc/cp/pt.c:15658 0x667f07 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../src-fix/gcc/cp/pt.c:14974 0x669b88 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) ../../src-fix/gcc/cp/pt.c:15146 0x6a8eb6 instantiate_decl(tree_node*, int, bool) ../../src-fix/gcc/cp/pt.c:21810 0x6afbeb instantiate_pending_templates(int) ../../src-fix/gcc/cp/pt.c:21927 0x6f08e1 c_parse_final_cleanups() ../../src-fix/gcc/cp/decl2.c:4589 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <http://gcc.gnu.org/bugs.html> for instructions. ////////////////////////////////////////////////////////////// template <class ValueType, ValueType> struct Option {}; template <class ValueType, ValueType Value, class OptionsRhs> auto operator|(Option<ValueType, Value>, OptionsRhs) { return Value; } enum canine_t { no, yes }; Option<canine_t, no> cat; Option<canine_t, yes> dog; template <class T> void f(T) { cat | dog; } struct A {}; int main() { f(A{}); return 0; } //////////////////////////////////////////////////////////////
4.8.x says: t990.cc:5:52: warning: 'operator|' function uses 'auto' type specifier without trailing return type [enabled by default] auto operator|(Option<ValueType, Value>, OptionsRhs) { ^
Author: ppalka Date: Sat Jan 16 02:37:09 2016 New Revision: 232463 URL: https://gcc.gnu.org/viewcvs?rev=232463&root=gcc&view=rev Log: Fix PR c++/69091 (ICE with operator overload having 'auto' return type) gcc/cp/ChangeLog: PR c++/69091 * pt.c (type_dependent_expression_p): For a function template specialization, a type is dependent iff any of its template arguments are. gcc/testsuite/ChangeLog: PR c++/69091 * g++.dg/template/pr69091.C: New test. Added: trunk/gcc/testsuite/g++.dg/template/pr69091.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/pt.c trunk/gcc/testsuite/ChangeLog
Fixed.