https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118839
--- Comment #1 from sandra at gcc dot gnu.org --- The C++ problem is actually much bigger than this: it's presently doing the variant lookup in completely the wrong place. The OpenMP 6.0 spec says in section 9.6.4 that for C++ "The function variant is determined by base language standard name lookup rules ([basic.lookup]) of variant-name using the argument types at the call site after implementation defined changes have been made according to the OpenMP context." Presently GCC is doing both name lookup and overload resolution as part of parsing of the declare variant directive instead. I think PR118791 is the issue tracking that already. I looked at trying to put a temporary band-aid on this. The confusing error message is happening from omp_declare_variant_finalize_one, the identifier_p (variant) case where it is calling perform_koenig_lookup or unqualified_fn_lookup_error. I believe we got an identifier passed through because the initial lookup attempt during parsing happened before the base function decl was created, so now it's deferring to koenig lookup of the name at the artificial call site. But now, the base function decl is present so it thinks that is a hint for the failed koenig lookup! So I'm not sure whether it's even worth trying to fix this independently of PR118791. The OpenMP spec doesn't say whether lookup of the variant happens before or after the base function declaration in C and Fortran; in GCC it happens after in both cases, so the missing diagnostic is pretty easily fixable.