https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115911
Bug ID: 115911 Summary: [OpenMP]gcc rejects valid user defined openmp reduction in template class with default argument Product: gcc Version: 13.2.0 Status: UNCONFIRMED Keywords: openmp, rejects-valid Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: rush102333 at gmail dot com Target Milestone: --- The following code is rejected by gcc-13.2: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $g++ -fsyntax-only -fopenmp tst.cpp template<typename T,int=0> struct A { #pragma omp declare reduction (add : T : omp_out += omp_in) initializer (omp_priv = 0) }; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The compiler outputs the following error message: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <source>:3:44: error: default argument for template parameter for class enclosing 'static void A<T, <anonymous> >::omp declare reduction add(T&)' 3 | #pragma omp declare reduction (add : T : omp_out += omp_in) initializer (omp_priv = 0) | ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Removing class A's default template argument "int=0" can eliminate the diagnostic. Clang and icc always accept the code. https://godbolt.org/z/3z36M8chv