Bug 69091 - [6 Regrssion] valid code with operator| causes ICE "tree check: accessed elt 2 of tree_vec with 1 elts in tsubst, at cp/pt.c:12851"
Summary: [6 Regrssion] valid code with operator| causes ICE "tree check: accessed elt ...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 6.0
: P3 normal
Target Milestone: 6.0
Assignee: Patrick Palka
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2015-12-30 17:04 UTC by ryan.burn
Modified: 2016-01-16 03:02 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2015-12-30 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ryan.burn 2015-12-30 17:04:54 UTC
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;
}
//////////////////////////////////////////////////////////////
Comment 1 Andrew Pinski 2015-12-30 21:11:04 UTC
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) {
                                                    ^
Comment 2 Patrick Palka 2016-01-16 02:37:41 UTC
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
Comment 3 Patrick Palka 2016-01-16 03:02:11 UTC
Fixed.