https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118791
Bug ID: 118791 Summary: declare variant messes up template instantiation with rvalue arguments Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: sandra at gcc dot gnu.org CC: burnus at gcc dot gnu.org, jakub at gcc dot gnu.org, waffl3x at protonmail dot com Target Milestone: --- Created attachment 60417 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=60417&action=edit test case quux.C Like PR118530, this was discovered by waffl3x and seems to be a problem with the template instantiation done by omp_declare_variant_finalize_one. $ x86_64-linux-gnu-g++ -fopenmp quux.C -S quux.C: In instantiation of 'void rvalue_int_variant(T&&) [with T = int]': quux.C:50:30: required by substitution of 'template<class T> void rvalue_int(T&&) [with T = int&&]' 50 | #pragma omp declare variant (rvalue_int_variant) match (implementation={vendor("gnu")}) | ^~~~~~~~~~~~~~~~~~ quux.C:78:20: required from here 78 | rvalue_int<int&&>(0); | ~~~~~~~~~~~~~~~~~^~~ quux.C:46:37: error: static assertion failed 46 | static_assert(is_same<T, int &&>::value); | ^~~~~ quux.C:46:37: note: 'is_same<int, int&&>::value' evaluates to false quux.C: In instantiation of 'void rvalue_const_int_variant(T&&) [with T = const int]': quux.C:64:30: required by substitution of 'template<class T> void rvalue_const_int(T&&) [with T = const int&&]' 64 | #pragma omp declare variant (rvalue_const_int_variant) match (implementation={vendor("gnu")}) | ^~~~~~~~~~~~~~~~~~~~~~~~ quux.C:79:32: required from here 79 | rvalue_const_int<int const&&>(static_cast<int const&&>(0)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ quux.C:60:42: error: static assertion failed 60 | static_assert(is_same<T, int const&&>::value); | ^~~~~ quux.C:60:42: note: 'is_same<const int, const int&&>::value' evaluates to false The template base functions rvalue_int and rvalue_const_int are being explicitly instantiated with T "int &&" and "int const &&", respectively, but the corresponding variants with "int" and "const int". (FWIW, I'm by no means an expert on this, just filing a bug report so I can mention it in an xfail in the test case.)