public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/107276] New: ICE Deducting return type from ill-formed structured binding name
@ 2022-10-16 0:48 johelegp at gmail dot com
2022-10-17 11:29 ` [Bug c++/107276] ICE Deducing " marxin at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: johelegp at gmail dot com @ 2022-10-16 0:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107276
Bug ID: 107276
Summary: ICE Deducting return type from ill-formed structured
binding name
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Keywords: ice-on-invalid-code
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
Target Milestone: ---
See https://compiler-explorer.com/z/6MqKTjKd7.
```C++
auto f(auto x) {
auto [y] = x;
return y;
}
int i = f(0);
```
```
<source>: In instantiation of 'auto f(auto:1) [with auto:1 = int]':
<source>:5:10: required from here
<source>:2:8: error: cannot decompose non-array non-class type 'int'
2 | auto [y] = x;
| ^~~
<source>:3:10: internal compiler error: tree check: expected non_lvalue_expr or
static_cast_expr, have error_mark in set_implicit_rvalue_p, at
cp/cp-tree.h:8688
3 | return y;
| ^
0x236ef7e internal_error(char const*, ...)
???:0
0x95b166 tree_check_failed(tree_node const*, char const*, int, char const*,
...)
???:0
0xc9d1ca do_auto_deduction(tree_node*, tree_node*, tree_node*, int,
auto_deduction_context, tree_node*, int)
???:0
0xd4e054 check_return_expr(tree_node*, bool*)
???:0
0xcf39f3 finish_return_stmt(tree_node*)
???:0
0xcad9e6 instantiate_decl(tree_node*, bool, bool)
???:0
0xb8e015 maybe_instantiate_decl(tree_node*)
???:0
0xb8fa9e mark_used(tree_node*, int)
???:0
0xad275e build_new_function_call(tree_node*, vec<tree_node*, va_gc,
vl_embed>**, int)
???:0
0xcf93c8 finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool,
bool, int)
???:0
0xc806a7 c_parse_file()
???:0
0xdbdef9 c_common_parse_file()
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1
```
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/107276] ICE Deducing return type from ill-formed structured binding name
2022-10-16 0:48 [Bug c++/107276] New: ICE Deducting return type from ill-formed structured binding name johelegp at gmail dot com
@ 2022-10-17 11:29 ` marxin at gcc dot gnu.org
2022-10-19 18:35 ` johelegp at gmail dot com
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-10-17 11:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107276
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2022-10-17
Status|UNCONFIRMED |WAITING
Ever confirmed|0 |1
CC| |marxin at gcc dot gnu.org
--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Can't reproduce the ICE.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/107276] ICE Deducing return type from ill-formed structured binding name
2022-10-16 0:48 [Bug c++/107276] New: ICE Deducting return type from ill-formed structured binding name johelegp at gmail dot com
2022-10-17 11:29 ` [Bug c++/107276] ICE Deducing " marxin at gcc dot gnu.org
@ 2022-10-19 18:35 ` johelegp at gmail dot com
2022-10-20 11:10 ` [Bug c++/107276] ICE Deducing return type from ill-formed structured binding name since r13-2905-g772d532e0ba1e4b2 marxin at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: johelegp at gmail dot com @ 2022-10-19 18:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107276
--- Comment #2 from Johel Ernesto Guerrero Peña <johelegp at gmail dot com> ---
I just compiled GCC and it still ICEs:
```cli
$ ../root/gcc/bin/g++ --version
g++ (GCC) 13.0.0 20221019 (experimental)
Copyright (C) 2022 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.
$ cat x.cpp
auto f(auto x) {
auto [y] = x;
return y;
}
int i = f(0);
$ ../root/gcc/bin/g++ -std=c++23 -c x.cpp
x.cpp: In instantiation of ‘auto f(auto:1) [with auto:1 = int]’:
x.cpp:5:10: required from here
x.cpp:2:8: error: cannot decompose non-array non-class type ‘int’
2 | auto [y] = x;
| ^~~
x.cpp:3:10: internal compiler error: tree check: expected non_lvalue_expr or
static_cast_expr, have error_mark in set_implicit_rvalue_p, at
cp/cp-tree.h:8689
3 | return y;
| ^
0x22ea70c internal_error(char const*, ...)
???:0
0x8e3b63 tree_check_failed(tree_node const*, char const*, int, char const*,
...)
???:0
0xbb8768 do_auto_deduction(tree_node*, tree_node*, tree_node*, int,
auto_deduction_context, tree_node*, int)
???:0
0xc6d039 check_return_expr(tree_node*, bool*)
???:0
0xc101f3 finish_return_stmt(tree_node*)
???:0
0xbee0a3 instantiate_decl(tree_node*, bool, bool)
???:0
0xa9b5f5 maybe_instantiate_decl(tree_node*)
???:0
0xa9cfa0 mark_used(tree_node*, int)
???:0
0x9dcd4b build_new_function_call(tree_node*, vec<tree_node*, va_gc,
vl_embed>**, int)
???:0
0xc16768 finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool,
bool, int)
???:0
0xb9949b c_parse_file()
???:0
0xcde1f1 c_common_parse_file()
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://bugs.archlinux.org/> for instructions.
```
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/107276] ICE Deducing return type from ill-formed structured binding name since r13-2905-g772d532e0ba1e4b2
2022-10-16 0:48 [Bug c++/107276] New: ICE Deducting return type from ill-formed structured binding name johelegp at gmail dot com
2022-10-17 11:29 ` [Bug c++/107276] ICE Deducing " marxin at gcc dot gnu.org
2022-10-19 18:35 ` johelegp at gmail dot com
@ 2022-10-20 11:10 ` marxin at gcc dot gnu.org
2022-10-20 12:57 ` mpolacek at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-10-20 11:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107276
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|ICE Deducing return type |ICE Deducing return type
|from ill-formed structured |from ill-formed structured
|binding name |binding name since
| |r13-2905-g772d532e0ba1e4b2
Status|WAITING |NEW
CC| |mpolacek at gcc dot gnu.org
--- Comment #3 from Martin Liška <marxin at gcc dot gnu.org> ---
Now I can reproduce it, started with r13-2905-g772d532e0ba1e4b2.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/107276] ICE Deducing return type from ill-formed structured binding name since r13-2905-g772d532e0ba1e4b2
2022-10-16 0:48 [Bug c++/107276] New: ICE Deducting return type from ill-formed structured binding name johelegp at gmail dot com
` (2 preceding siblings ...)
2022-10-20 11:10 ` [Bug c++/107276] ICE Deducing return type from ill-formed structured binding name since r13-2905-g772d532e0ba1e4b2 marxin at gcc dot gnu.org
@ 2022-10-20 12:57 ` mpolacek at gcc dot gnu.org
2022-10-24 18:07 ` cvs-commit at gcc dot gnu.org
2022-10-24 18:08 ` mpolacek at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-10-20 12:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107276
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org
Status|NEW |ASSIGNED
--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Mine.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/107276] ICE Deducing return type from ill-formed structured binding name since r13-2905-g772d532e0ba1e4b2
2022-10-16 0:48 [Bug c++/107276] New: ICE Deducting return type from ill-formed structured binding name johelegp at gmail dot com
` (3 preceding siblings ...)
2022-10-20 12:57 ` mpolacek at gcc dot gnu.org
@ 2022-10-24 18:07 ` cvs-commit at gcc dot gnu.org
2022-10-24 18:08 ` mpolacek at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-10-24 18:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107276
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:
https://gcc.gnu.org/g:f7d8ccfda2d5c90dac97b1a3ede8b10391a3cc40
commit r13-3462-gf7d8ccfda2d5c90dac97b1a3ede8b10391a3cc40
Author: Marek Polacek <polacek@redhat.com>
Date: Thu Oct 20 15:55:28 2022 -0400
c++: ICE with invalid structured bindings [PR107276]
This test ICEs in C++23 because we reach the new code in do_auto_deduction:
30468 if (cxx_dialect >= cxx23
30469 && context == adc_return_type
30470 && (!AUTO_IS_DECLTYPE (auto_node)
30471 || !unparenthesized_id_or_class_member_access_p (init))
30472 && (r = treat_lvalue_as_rvalue_p (maybe_undo_parenthesized_ref
(init),
30473 /*return*/true)))
where 'init' is "VIEW_CONVERT_EXPR<<<< error >>>>(y)", and then the move
in treat_lvalue_as_rvalue_p returns error_mark_node whereupon
set_implicit_rvalue_p crashes.
I don't think such V_C_Es are useful so let's not create them. But that
won't fix the ICE so I'm checking the return value of move. A structured
bindings decl can have an error type, that is set in cp_finish_decomp:
8908 TREE_TYPE (first) = error_mark_node;
therefore I think treat_lvalue_as_rvalue_p just needs to cope.
PR c++/107276
gcc/cp/ChangeLog:
* typeck.cc (treat_lvalue_as_rvalue_p): Check the return value of
move.
gcc/ChangeLog:
* tree.cc (maybe_wrap_with_location): Don't create a location
wrapper
when the type is erroneous.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/decomp4.C: New test.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/107276] ICE Deducing return type from ill-formed structured binding name since r13-2905-g772d532e0ba1e4b2
2022-10-16 0:48 [Bug c++/107276] New: ICE Deducting return type from ill-formed structured binding name johelegp at gmail dot com
` (4 preceding siblings ...)
2022-10-24 18:07 ` cvs-commit at gcc dot gnu.org
@ 2022-10-24 18:08 ` mpolacek at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-10-24 18:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107276
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #6 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-10-24 18:08 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-16 0:48 [Bug c++/107276] New: ICE Deducting return type from ill-formed structured binding name johelegp at gmail dot com
2022-10-17 11:29 ` [Bug c++/107276] ICE Deducing " marxin at gcc dot gnu.org
2022-10-19 18:35 ` johelegp at gmail dot com
2022-10-20 11:10 ` [Bug c++/107276] ICE Deducing return type from ill-formed structured binding name since r13-2905-g772d532e0ba1e4b2 marxin at gcc dot gnu.org
2022-10-20 12:57 ` mpolacek at gcc dot gnu.org
2022-10-24 18:07 ` cvs-commit at gcc dot gnu.org
2022-10-24 18:08 ` mpolacek at gcc dot gnu.org
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).