https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118486
Bug ID: 118486
Summary: [OpenMP] declare_variant - bogus diagnostic 'not
found' when only return-type is wrong
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Keywords: diagnostic, openmp
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: ---
GCC [12 to mainline/15] shows:
foo.c:3:29: error: could not find variant declaration
3 | #pragma omp declare variant(expl) match(user={condition(1)})
| ^~~~
While Clang-19 is much more helpful:
foo555.c:3:29: error: variant in '#pragma omp declare variant' with type
'NotAnInt ()' is incompatible with type 'int ()'
3 | #pragma omp declare variant(expl) match(user={condition(1)})
| ^~~~
struct NotAnInt {};
NotAnInt expl();
#pragma omp declare variant(expl) match(user={condition(1)})
int base();
//...
void f() {
//...
int x;
// assume this matches
x = base();
}
When specifying multiple same-named functions, e.g.
NotAnInt expl();
float expl(float);
g++ still prints the same error while clang++-19 then prints:
error: variant in '#pragma omp declare variant' with type '<overloaded function
type>' is incompatible with type 'int ()'
* * *
Thus, when there is only one candidate, GCC shall be more much more helpful,
but also when there are multiple, which aren't quite right, it should be more
helpful than now.
* * *
Crossref: Slightly related to OpenMP Spec Issue #4446.