https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109490
Bug ID: 109490
Summary: ICE when using custom OpenMP reduction in Lambda in
Template Function
Product: gcc
Version: 12.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: simon-pfahler at gmx dot de
Target Milestone: ---
Created attachment 54844
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54844&action=edit
preprocessed file
g++ throws an ICE when trying to compile the following code:
template <class T> T add(int const &maxs) {
auto step = [&](auto const &maxs) {
T a = T(0);
#pragma omp declare reduction(MyRed:T
\
: omp_out += omp_in)
\
initializer(omp_priv(omp_orig))
#pragma omp parallel for schedule(dynamic, 10) reduction(MyRed : a)
for (int s = 0; s <= maxs; ++s) {
a += T(1);
}
return a;
};
return step(maxs);
}
int main() { auto a = add<double>(100); }
Additional info:
gcc -v:
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --enable-bootstrap
--prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/
--with-build-config=bootstrap-lto --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-libstdcxx-backtrace --enable-link-serialization=1
--enable-linker-build-id --enable-lto --enable-multilib --enable-plugin
--enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch
--disable-werror
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.2.1 20230201 (GCC)
Complete command line:
g++ -fopenmp main.cpp
Compiler output message:
main.cpp: In instantiation of ‘T add(const int&) [with T = double]’:
main.cpp:17:34: required from here
main.cpp:4:9: internal compiler error: in instantiate_body, at cp/pt.cc:26443
4 | #pragma omp declare reduction(MyRed:T
\
| ^~~
0x19ea0c8 internal_error(char const*, ...)
???:0
0x6543f0 fancy_abort(char const*, int, char const*)
???:0
0x7f843c tsubst_lambda_expr(tree_node*, tree_node*, int, tree_node*)
???:0
0x7e258f tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
???:0
0x7db493 instantiate_decl(tree_node*, bool, bool)
???:0
0x7f9a73 instantiate_pending_templates(int)
???:0
0x6fe658 c_parse_final_cleanups()
???: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.
Preprocessed file (*.ii) is attached.
Let me know if there is information missing.