public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libgomp/105839] New: internal compiler error: in tsubst_omp_for_iterator, at cp/pt.cc:18122 (instantiate_pending_templates -> instantiate_decl -> tsubst_lambda_expr)
@ 2022-06-03 16:49 northon_patrick3 at yahoo dot ca
2022-06-03 17:07 ` [Bug c++/105839] " jakub at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: northon_patrick3 at yahoo dot ca @ 2022-06-03 16:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105839
Bug ID: 105839
Summary: internal compiler error: in tsubst_omp_for_iterator,
at cp/pt.cc:18122 (instantiate_pending_templates ->
instantiate_decl -> tsubst_lambda_expr)
Product: gcc
Version: 12.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libgomp
Assignee: unassigned at gcc dot gnu.org
Reporter: northon_patrick3 at yahoo dot ca
CC: jakub at gcc dot gnu.org
Target Milestone: ---
Created attachment 53079
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53079&action=edit
Result from -freport-bug
The code:
```
void test(const auto &b1)
{
const auto loopImpl = [&](auto&& fc)
{
#pragma omp parallel for
for(auto&& [v1, v2] : b1);
};
loopImpl([]{});
}
void test2()
{
int a[10];
test(a);
}
```
The command line:
```
g++ -fopenmp test.cpp
```
The error:
```
internal compiler error: in tsubst_omp_for_iterator, at cp/pt.cc:18126
11 | for(auto&& [v1, v2] : b1);
| ^~~
0x1ac4724 internal_error(char const*, ...)
???:0
0x663b55 fancy_abort(char const*, int, char const*)
???:0
0x81d054 tsubst_lambda_expr(tree_node*, tree_node*, int, tree_node*)
???:0
0x80614a tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
???:0
0x7fedbe instantiate_decl(tree_node*, bool, bool)
???:0
0x81e704 instantiate_pending_templates(int)
???:0
0x7173d1 c_parse_final_cleanups()
???:0
```
GCC is configured with:
```
configure --prefix=/opt/pat-gcc --libdir=/opt/pat-gcc/lib
--libexecdir=/opt/pat-gcc/lib --enable-languages=c,c++,lto --with-isl
--with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit
--enable-cet=auto --enable-checking=release --enable-clocale=gnu
--enable-default-pie --enable-default-ssp --enable-gnu-indirect-function
--enable-gnu-unique-object --enable-install-libiberty --enable-linker-build-id
--enable-lto --enable-multilib --enable-plugin --enable-shared
--enable-threads=posix --disable-libssp --disable-libstdcxx-pch
--disable-libunwind-exceptions --disable-werror
gdc_include_dir=/opt/pat-gcc/include/dlang/gdc
```
It happens from version 10.1 to latest commit at this date.
It no longer crash if:
- I don't use structured bindings.
- b1 isn't a template.
- I remove `auto&& fc`.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/105839] internal compiler error: in tsubst_omp_for_iterator, at cp/pt.cc:18122 (instantiate_pending_templates -> instantiate_decl -> tsubst_lambda_expr)
2022-06-03 16:49 [Bug libgomp/105839] New: internal compiler error: in tsubst_omp_for_iterator, at cp/pt.cc:18122 (instantiate_pending_templates -> instantiate_decl -> tsubst_lambda_expr) northon_patrick3 at yahoo dot ca
@ 2022-06-03 17:07 ` jakub at gcc dot gnu.org
2023-03-01 11:10 ` [Bug c++/105839] internal compiler error: in tsubst_omp_for_iterator with openmp and structured bindings in a template jakub at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-06-03 17:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105839
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Adjusted testcase, so that it is already valid C++17:
template <typename T>
void
foo (const T &x)
{
[&] (auto&& y)
{
#pragma omp parallel for
for (auto&& [v1, v2] : x)
;
} ([]{});
}
void
bar ()
{
int a[10];
foo (a);
}
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/105839] internal compiler error: in tsubst_omp_for_iterator with openmp and structured bindings in a template
2022-06-03 16:49 [Bug libgomp/105839] New: internal compiler error: in tsubst_omp_for_iterator, at cp/pt.cc:18122 (instantiate_pending_templates -> instantiate_decl -> tsubst_lambda_expr) northon_patrick3 at yahoo dot ca
2022-06-03 17:07 ` [Bug c++/105839] " jakub at gcc dot gnu.org
@ 2023-03-01 11:10 ` jakub at gcc dot gnu.org
2023-03-01 11:47 ` jakub at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-03-01 11:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105839
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords|ice-on-valid-code |
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Actually, I don't see how it can be valid.
x (or b1) is const int[10] & and structured binding on int is clearly invalid.
The ICE got fixed in r13-4460-gee4f25999f6832a1c, except that since
r13-5379-gd427407a199a0c276cb02 we ICE again with -fopenmp -std=c++11 (error
recovery
after emitting some errors).
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/105839] internal compiler error: in tsubst_omp_for_iterator with openmp and structured bindings in a template
2022-06-03 16:49 [Bug libgomp/105839] New: internal compiler error: in tsubst_omp_for_iterator, at cp/pt.cc:18122 (instantiate_pending_templates -> instantiate_decl -> tsubst_lambda_expr) northon_patrick3 at yahoo dot ca
2022-06-03 17:07 ` [Bug c++/105839] " jakub at gcc dot gnu.org
2023-03-01 11:10 ` [Bug c++/105839] internal compiler error: in tsubst_omp_for_iterator with openmp and structured bindings in a template jakub at gcc dot gnu.org
@ 2023-03-01 11:47 ` jakub at gcc dot gnu.org
2023-03-01 11:52 ` northon_patrick3 at yahoo dot ca
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-03-01 11:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105839
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 54564
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54564&action=edit
gcc13-pr105839.patch
Untested fix for the error recovery issue.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/105839] internal compiler error: in tsubst_omp_for_iterator with openmp and structured bindings in a template
2022-06-03 16:49 [Bug libgomp/105839] New: internal compiler error: in tsubst_omp_for_iterator, at cp/pt.cc:18122 (instantiate_pending_templates -> instantiate_decl -> tsubst_lambda_expr) northon_patrick3 at yahoo dot ca
` (2 preceding siblings ...)
2023-03-01 11:47 ` jakub at gcc dot gnu.org
@ 2023-03-01 11:52 ` northon_patrick3 at yahoo dot ca
2023-03-01 12:01 ` jakub at gcc dot gnu.org
2023-03-02 8:07 ` cvs-commit at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: northon_patrick3 at yahoo dot ca @ 2023-03-01 11:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105839
--- Comment #4 from northon_patrick3 at yahoo dot ca ---
Actually is still crash even on valid code:
```
template <typename T>
void
foo (const T &x)
{
[&] (auto&& y)
{
#pragma omp parallel for
for (auto&& [v1, v2] : x)
;
} ([]{});
}
struct A { int a, b; };
void
bar ()
{
A a[10];
foo (a);
}
```
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/105839] internal compiler error: in tsubst_omp_for_iterator with openmp and structured bindings in a template
2022-06-03 16:49 [Bug libgomp/105839] New: internal compiler error: in tsubst_omp_for_iterator, at cp/pt.cc:18122 (instantiate_pending_templates -> instantiate_decl -> tsubst_lambda_expr) northon_patrick3 at yahoo dot ca
` (3 preceding siblings ...)
2023-03-01 11:52 ` northon_patrick3 at yahoo dot ca
@ 2023-03-01 12:01 ` jakub at gcc dot gnu.org
2023-03-02 8:07 ` cvs-commit at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-03-01 12:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105839
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Not on the trunk. Note, the r13-4460, r13-4461, r13-5379 changes PR84469
changes weren't backported to older branches intentionally, it is quite risky
and had multiple follow-ups.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/105839] internal compiler error: in tsubst_omp_for_iterator with openmp and structured bindings in a template
2022-06-03 16:49 [Bug libgomp/105839] New: internal compiler error: in tsubst_omp_for_iterator, at cp/pt.cc:18122 (instantiate_pending_templates -> instantiate_decl -> tsubst_lambda_expr) northon_patrick3 at yahoo dot ca
` (4 preceding siblings ...)
2023-03-01 12:01 ` jakub at gcc dot gnu.org
@ 2023-03-02 8:07 ` cvs-commit at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-03-02 8:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105839
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:f0ef740d54f47ff614eb02e13e8f4cb11dfbb140
commit r13-6407-gf0ef740d54f47ff614eb02e13e8f4cb11dfbb140
Author: Jakub Jelinek <jakub@redhat.com>
Date: Thu Mar 2 09:02:12 2023 +0100
openmp: Fix up error recovery for invalid structured bindings in OpenMP
range for loops [PR105839]
The PR108503 temporary DECL_HAS_VALUE_EXPR_P clearing code can ICE
during recovery, because cp_finish_decomp when it detects errors and
reports them clears DECL_HAS_VALUE_EXPR_P, clears DECL_VALUE_EXPR and
sets TREE_TYPE of the structured binding vars to error_mark_node.
The PR108503 code had an assertion that DECL_HAS_VALUE_EXPR_P is set
so that it can clear it and restore later.
The following patch allows DECL_HAS_VALUE_EXPR_P to be unset if
type is error_mark_node and doesn't set it again in that case.
2023-03-02 Jakub Jelinek <jakub@redhat.com>
PR c++/105839
* parser.cc (cp_convert_omp_range_for): Allow in assert
decomp_first_name without DECL_HAS_VALUE_EXPR_P if it has
error_mark_node type.
(cp_finish_omp_range_for): Don't set DECL_HAS_VALUE_EXPR_P back
on decls which have error_mark_node type.
* g++.dg/gomp/pr105839-1.C: New test.
* g++.dg/gomp/pr105839-2.C: New test.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-03-02 8:07 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-03 16:49 [Bug libgomp/105839] New: internal compiler error: in tsubst_omp_for_iterator, at cp/pt.cc:18122 (instantiate_pending_templates -> instantiate_decl -> tsubst_lambda_expr) northon_patrick3 at yahoo dot ca
2022-06-03 17:07 ` [Bug c++/105839] " jakub at gcc dot gnu.org
2023-03-01 11:10 ` [Bug c++/105839] internal compiler error: in tsubst_omp_for_iterator with openmp and structured bindings in a template jakub at gcc dot gnu.org
2023-03-01 11:47 ` jakub at gcc dot gnu.org
2023-03-01 11:52 ` northon_patrick3 at yahoo dot ca
2023-03-01 12:01 ` jakub at gcc dot gnu.org
2023-03-02 8:07 ` cvs-commit 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).