https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117803
Bug ID: 117803
Summary: [OpenMP] Rejects valid with TEMPLATES in DECLARE
VARIANT resolution
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
CC: jakub at gcc dot gnu.org
Target Milestone: ---
https://godbolt.org/z/zjKshK35K - the example in the compiler explorer.
The following code seems to be valid but is rejected with:
<source>:3:29: error: no matching function for call to 'repl1()'
3 | #pragma omp declare variant(repl1) match(construct={dispatch})
| ^~~~~
<source>:2:3: note: candidate: 'template<class T> T repl1()'
2 | T repl1();
| ^~~~~
<source>:2:3: note: template argument deduction/substitution failed:
<source>:3:29: note: couldn't deduce template parameter 'T'
3 | #pragma omp declare variant(repl1) match(construct={dispatch})
| ^~~~~
* * *
Intel's ICX accepts all but the 'base2' calls.
Likewise for Clang, except that 'omp dispatch' has to be commented out
(unsupported).
g++ accepts the code with -fno-openmp but otherwise rejects the base1, base2
and base3 – already early, i.e. without instantiation.
* * *
template<typename T>
T repl1();
#pragma omp declare variant(repl1) match(construct={dispatch})
template<typename T>
T base1();
template<typename T>
float repl2();
#pragma omp declare variant(repl2) match(construct={dispatch})
template<typename T>
float base2();
template<typename T>
float repl3(T);
#pragma omp declare variant(repl3) match(construct={dispatch})
template<typename T>
float base3(T);
void f()
{
int x; float y;
x = base1<int>();
y = base2<int>();
y = base3<int>(5);
#pragma omp dispatch
x = base1<int>();
#pragma omp dispatch
y = base2<int>();
#pragma omp dispatch
y = base3<int>(5);
}