public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/95999] New: ICE in tree check: expected integer_cst, have var_decl in get_len, at tree.h:5951
@ 2020-06-30 20:29 webrown.cpp at gmail dot com
2020-07-01 15:14 ` [Bug c++/95999] " mpolacek at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: webrown.cpp at gmail dot com @ 2020-06-30 20:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95999
Bug ID: 95999
Summary: ICE in tree check: expected integer_cst, have var_decl
in get_len, at tree.h:5951
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Keywords: error-recovery, ice-on-invalid-code
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: haoxintu at gmail dot com
CC: webrown.cpp at gmail dot com
Target Milestone: ---
CC: webrown.cpp at gmail dot com
This code, bug.cc, reduced by C-Reduce, makes GCC-trunk ICE.
$cat bug.cc
int a;
enum struct b;
template <typename = enum struct b { c = a d }
template <> enum struct b { e };
$g++ bug.cc
bug.cc:3:42: error: the value of ‘a’ is not usable in a constant expression
3 | template <typename = enum struct b { c = a d }
| ^
bug.cc:1:5: note: ‘int a’ is not const
1 | int a;
| ^
bug.cc:3:44: error: expected ‘}’ before ‘d’
3 | template <typename = enum struct b { c = a d }
| ~ ^
bug.cc:3:44: error: expected ‘>’ before ‘d’
bug.cc:3:46: error: expected unqualified-id before ‘}’ token
3 | template <typename = enum struct b { c = a d }
| ^
bug.cc:3:46: error: expected declaration before ‘}’ token
bug.cc:4:29: internal compiler error: tree check: expected integer_cst, have
var_decl in get_len, at tree.h:5951
4 | template <> enum struct b { e };
| ^
0x7c2dcf tree_check_failed(tree_node const*, char const*, int, char const*,
...)
../../gcc/tree.c:9685
0x61582f tree_check(tree_node const*, char const*, int, char const*, tree_code)
../../gcc/tree.h:3557
0x61582f wi::extended_tree<192>::get_len() const
../../gcc/tree.h:5951
0x61582f wi::int_traits<generic_wide_int<wi::extended_tree<192> >
>::decompose(long*, unsigned int, generic_wide_int<wi::extended_tree<192> >
const&)
../../gcc/wide-int.h:985
0x61582f wide_int_ref_storage<true,
false>::wide_int_ref_storage<generic_wide_int<wi::extended_tree<192> >
>(generic_wide_int<wi::extended_tree<192> > const&, unsigned int)
../../gcc/wide-int.h:1034
0x61582f generic_wide_int<wide_int_ref_storage<true, false>
>::generic_wide_int<generic_wide_int<wi::extended_tree<192> >
>(generic_wide_int<wi::extended_tree<192> > const&, unsigned int)
../../gcc/wide-int.h:790
0x61582f wi::binary_traits<generic_wide_int<wi::extended_tree<192> >, int,
wi::int_traits<generic_wide_int<wi::extended_tree<192> > >::precision_type,
wi::int_traits<int>::precision_type>::result_type
wi::add<generic_wide_int<wi::extended_tree<192> >,
int>(generic_wide_int<wi::extended_tree<192> > const&, int const&, signop,
wi::overflow_type*)
../../gcc/wide-int.h:2467
0x61582f build_enumerator(tree_node*, tree_node*, tree_node*, tree_node*,
unsigned int)
../../gcc/cp/decl.c:15857
0x9a2447 cp_parser_enumerator_definition
../../gcc/cp/parser.c:19545
0x9a2447 cp_parser_enumerator_list
../../gcc/cp/parser.c:19474
0x9a2447 cp_parser_enum_specifier
../../gcc/cp/parser.c:19405
0x9a2447 cp_parser_type_specifier
../../gcc/cp/parser.c:17734
0x9a2a02 cp_parser_decl_specifier_seq
../../gcc/cp/parser.c:14410
0x9c8f35 cp_parser_single_declaration
../../gcc/cp/parser.c:29459
0x9ca0f0 cp_parser_explicit_specialization
../../gcc/cp/parser.c:17654
0x9ccac9 cp_parser_declaration
../../gcc/cp/parser.c:13430
0x9cd06a cp_parser_translation_unit
../../gcc/cp/parser.c:4761
0x9cd06a c_parse_file()
../../gcc/cp/parser.c:44043
0xae4dbb c_common_parse_file()
../../gcc/c-family/c-opts.c:1190
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
$g++ --version
g++ (GCC) 11.0.0 20200626 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/95999] ICE in tree check: expected integer_cst, have var_decl in get_len, at tree.h:5951
2020-06-30 20:29 [Bug c++/95999] New: ICE in tree check: expected integer_cst, have var_decl in get_len, at tree.h:5951 webrown.cpp at gmail dot com
@ 2020-07-01 15:14 ` mpolacek at gcc dot gnu.org
2021-08-08 9:03 ` [Bug c++/95999] [9/10/11/12 Regression] " pinskia at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-07-01 15:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95999
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Last reconfirmed| |2020-07-01
CC| |mpolacek at gcc dot gnu.org
Status|UNCONFIRMED |NEW
--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Started with r265055.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/95999] [9/10/11/12 Regression] ICE in tree check: expected integer_cst, have var_decl in get_len, at tree.h:5951
2020-06-30 20:29 [Bug c++/95999] New: ICE in tree check: expected integer_cst, have var_decl in get_len, at tree.h:5951 webrown.cpp at gmail dot com
2020-07-01 15:14 ` [Bug c++/95999] " mpolacek at gcc dot gnu.org
@ 2021-08-08 9:03 ` pinskia at gcc dot gnu.org
2022-01-21 13:30 ` rguenth at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-08 9:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95999
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |9.5
Severity|normal |trivial
Summary|ICE in tree check: expected |[9/10/11/12 Regression] ICE
|integer_cst, have var_decl |in tree check: expected
|in get_len, at tree.h:5951 |integer_cst, have var_decl
| |in get_len, at tree.h:5951
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/95999] [9/10/11/12 Regression] ICE in tree check: expected integer_cst, have var_decl in get_len, at tree.h:5951
2020-06-30 20:29 [Bug c++/95999] New: ICE in tree check: expected integer_cst, have var_decl in get_len, at tree.h:5951 webrown.cpp at gmail dot com
2020-07-01 15:14 ` [Bug c++/95999] " mpolacek at gcc dot gnu.org
2021-08-08 9:03 ` [Bug c++/95999] [9/10/11/12 Regression] " pinskia at gcc dot gnu.org
@ 2022-01-21 13:30 ` rguenth at gcc dot gnu.org
2022-02-21 12:29 ` roger at nextmovesoftware dot com
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-01-21 13:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95999
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P4
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/95999] [9/10/11/12 Regression] ICE in tree check: expected integer_cst, have var_decl in get_len, at tree.h:5951
2020-06-30 20:29 [Bug c++/95999] New: ICE in tree check: expected integer_cst, have var_decl in get_len, at tree.h:5951 webrown.cpp at gmail dot com
` (2 preceding siblings ...)
2022-01-21 13:30 ` rguenth at gcc dot gnu.org
@ 2022-02-21 12:29 ` roger at nextmovesoftware dot com
2022-03-10 7:43 ` cvs-commit at gcc dot gnu.org
2022-03-10 23:01 ` roger at nextmovesoftware dot com
5 siblings, 0 replies; 7+ messages in thread
From: roger at nextmovesoftware dot com @ 2022-02-21 12:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95999
Roger Sayle <roger at nextmovesoftware dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
CC| |roger at nextmovesoftware dot com
Assignee|unassigned at gcc dot gnu.org |roger at nextmovesoftware dot com
--- Comment #2 from Roger Sayle <roger at nextmovesoftware dot com> ---
Patch proposed.
https://gcc.gnu.org/pipermail/gcc-patches/2022-February/590653.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/95999] [9/10/11/12 Regression] ICE in tree check: expected integer_cst, have var_decl in get_len, at tree.h:5951
2020-06-30 20:29 [Bug c++/95999] New: ICE in tree check: expected integer_cst, have var_decl in get_len, at tree.h:5951 webrown.cpp at gmail dot com
` (3 preceding siblings ...)
2022-02-21 12:29 ` roger at nextmovesoftware dot com
@ 2022-03-10 7:43 ` cvs-commit at gcc dot gnu.org
2022-03-10 23:01 ` roger at nextmovesoftware dot com
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-03-10 7:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95999
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Roger Sayle <sayle@gcc.gnu.org>:
https://gcc.gnu.org/g:bae10419f6e07dbde8e66ff4ff70d050f82ad451
commit r12-7574-gbae10419f6e07dbde8e66ff4ff70d050f82ad451
Author: Roger Sayle <roger@nextmovesoftware.com>
Date: Thu Mar 10 07:41:12 2022 +0000
PR c++/95999: Improved error recovery in enumeration lists.
This patch resolves PR c++/95999 which is an ICE-after-error regression
in the g++ front-end. When parsing an enumerator list, the C++ parser
assumes that cp_parser_constant_expression always returns either an
INTEGER_CST or error_mark_node, but in the testcase reported in the
PR, it actually returns a VAR_DECL.
The usual (but perhaps controversial) design philosophy is that the
routine that reports the error normally has a duty to indicate this to
the rest of the compiler (via error_mark_node), but here the return
value from calling require_rvalue_constant_expression (parser.cc:10666)
is ignored. I initially experimented with setting EXPRESSION to
error_mark_node here in cp_parser_constant_expression but (perhaps
conveniently) that's insufficient to resolve the problem. The simple
fix in this patch is to tweak the two places that require INTEGER_CST
to treat all other tree types as though they are error_mark_node.
2022-03-10 Roger Sayle <roger@nextmovesoftware.com>
gcc/cp/ChangeLog
PR c++/95999
* decl.cc (finish_enum_value_list): If VALUE isn't an INTEGER_CST
consider it to be zero (i.e. treat it like error_mark_node).
(build_enumerator): Likewise, if PREV_VALUE isn't an INTEGER_CST,
set VALUE to error_mark_node.
gcc/testsuite/ChangeLog
PR c++/95999
* g++.dg/parse/pr95999.C: New test case.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/95999] [9/10/11/12 Regression] ICE in tree check: expected integer_cst, have var_decl in get_len, at tree.h:5951
2020-06-30 20:29 [Bug c++/95999] New: ICE in tree check: expected integer_cst, have var_decl in get_len, at tree.h:5951 webrown.cpp at gmail dot com
` (4 preceding siblings ...)
2022-03-10 7:43 ` cvs-commit at gcc dot gnu.org
@ 2022-03-10 23:01 ` roger at nextmovesoftware dot com
5 siblings, 0 replies; 7+ messages in thread
From: roger at nextmovesoftware dot com @ 2022-03-10 23:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95999
Roger Sayle <roger at nextmovesoftware dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|9.5 |12.0
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #4 from Roger Sayle <roger at nextmovesoftware dot com> ---
This should now be fixed on mainline.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-03-10 23:01 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-30 20:29 [Bug c++/95999] New: ICE in tree check: expected integer_cst, have var_decl in get_len, at tree.h:5951 webrown.cpp at gmail dot com
2020-07-01 15:14 ` [Bug c++/95999] " mpolacek at gcc dot gnu.org
2021-08-08 9:03 ` [Bug c++/95999] [9/10/11/12 Regression] " pinskia at gcc dot gnu.org
2022-01-21 13:30 ` rguenth at gcc dot gnu.org
2022-02-21 12:29 ` roger at nextmovesoftware dot com
2022-03-10 7:43 ` cvs-commit at gcc dot gnu.org
2022-03-10 23:01 ` roger at nextmovesoftware dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).