https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118488
Bug ID: 118488 Summary: [OpenMP] Return types and templates with 'declare variant' mishandled Product: gcc Version: 15.0 Status: UNCONFIRMED Keywords: openmp, rejects-valid Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: burnus at gcc dot gnu.org Target Milestone: --- Cf. discussion at OpenMP spec Issue 4371. The following code compiles with clang++-19 but is rejected by GCC; the current thought is that it is supposed to be valid. (Even if at the end the substitution would be invalid like in: myClass var3(); #pragma omp declare variant(var3) match(...) template<typename T3> base3 (); when being called with "int x = base3<int>();". See also PR118486.) * * * template<typename T2> T2 expl1(); int expl2(); #pragma omp declare variant(expl1) match(user={condition(true)}) #pragma omp declare variant(expl2) match(user={condition(true)}) template<typename T> T base(); void f() { int x; x = base<int>(); } GCC rejects it with: error: variant ‘int expl2()’ and base ‘T base()’ have incompatible types and error: no matching function for call to ‘expl1()’ note: candidate: ‘template<class T2> T2 expl1()’ note: template argument deduction/substitution failed: note: couldn’t deduce template parameter ‘T2’