[Bug c++/69091] New: valid code with operator| causes ICE "tree check: accessed elt 2 of tree_vec with 1 elts in tsubst, at cp/pt.c:12851"

ryan.burn at gmail dot com gcc-bugzilla@gcc.gnu.org
Wed Dec 30 17:04:00 GMT 2015


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69091

            Bug ID: 69091
           Summary: valid code with operator| causes ICE "tree check:
                    accessed elt 2 of tree_vec with 1 elts in tsubst, at
                    cp/pt.c:12851"
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ryan.burn at gmail dot com
  Target Milestone: ---

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;
}
//////////////////////////////////////////////////////////////


More information about the Gcc-bugs mailing list