[Bug c++/118791] declare variant messes up template instantiation with rvalue arguments

2025-02-09 Thread burnus at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118791

Tobias Burnus  changed:

   What|Removed |Added

 CC||jason at redhat dot com

--- Comment #5 from Tobias Burnus  ---
(In reply to sandra from comment #3)
> Curiously, on the OG14 development branch the rvalue calls work but the
> lvalue ones are broken instead:

Confirmed with GCC 14.

This is caused by the following patch - which changes whether one or the
other fails in the static assert. Namely:

// FAILS with:  7eec6fedf45
// OK with  dd3f3c71df6
  int lvalue = 0;
  lvalue_int(lvalue);
  lvalue_const_int(static_cast(lvalue));

// OK for:  7eec6fedf45
// FAILS with dd3f3c71df6
  rvalue_int(0);
  rvalue_const_int(static_cast(0));

* * *

The patch that caused the flip is:

r15-6707-gdd3f3c71df66ed

commit dd3f3c71df66ed6fd3872ab780f5813831100d1c (HEAD)
Author: Jason Merrill
AuthorDate: Mon Dec 23 19:57:56 2024 -0500
CommitDate: Wed Jan 8 16:34:58 2025 -0500

c++: fix conversion issues

Some issues caught by a check from another patch:

In the convert_like_internal bad_p handling, we are iterating from outside
to inside, so once we recurse into convert_like we need to stop looping.

In build_ramp_function, we're assigning REFERENCE_TYPE things, so we need
to
build the assignment directly rather than rely on functions that implement
C++ semantics.

In omp_declare_variant_finalize_one, the parameter object building failed
to
handle reference parms, and it seems simpler to just use build_stub_object
like other parts of the compiler.

gcc/cp/ChangeLog:

* call.cc (convert_like_internal): Add missing break.
* coroutines.cc (cp_coroutine_transform::build_ramp_function):
Build
INIT_EXPR directly.
* decl.cc (omp_declare_variant_finalize_one): Use
build_stub_object.

gcc/testsuite/ChangeLog:

* g++.dg/gomp/declare-variant-3.C: Don't depend on expr dump.
* g++.dg/gomp/declare-variant-5.C: Likewise.

[Bug c++/118791] declare variant messes up template instantiation with rvalue arguments

2025-02-09 Thread sandra at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118791

--- Comment #4 from sandra at gcc dot gnu.org ---
Ooops, I meant "specific to OG14 branch" in my last comment.

[Bug c++/118791] declare variant messes up template instantiation with rvalue arguments

2025-02-09 Thread sandra at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118791

--- Comment #3 from sandra at gcc dot gnu.org ---
Curiously, on the OG14 development branch the rvalue calls work but the lvalue
ones are broken instead:

$ install/bin/x86_64-none-linux-gnu-g++ -fopenmp -S quux.C 
quux.C: In instantiation of 'void lvalue_int_variant(T&&) [with T = int&&]':
quux.C:21:30:   required by substitution of 'template void
lvalue_int(T&&) [with T = int&]'
   21 | #pragma omp declare variant (lvalue_int_variant) match
(implementation={vendor("gnu")})
  |  ^~
quux.C:76:19:   required from here
   76 |   lvalue_int(lvalue);
  |   ^~~~
quux.C:16:35: error: static assertion failed
   16 |   static_assert(is_same::value);
  |   ^
quux.C:16:35: note: 'is_same::value' evaluates to false
quux.C: In instantiation of 'void lvalue_const_int_variant(T&&) [with T = const
int&&]':
quux.C:36:30:   required by substitution of 'template void
lvalue_const_int(T&&) [with T = const int&]'
   36 | #pragma omp declare variant (lvalue_const_int_variant) match
(implementation={vendor("gnu")})
  |  ^~~~
quux.C:77:31:   required from here
   77 |   lvalue_const_int(static_cast(lvalue));
  |   ^
quux.C:31:41: error: static assertion failed
   31 |   static_assert(is_same::value);
  | ^
quux.C:31:41: note: 'is_same::value' evaluates to
false

So this might actually be a regression in GCC 15 -- perhaps the fix for the
lvalue case ended up breaking the rvalue case instead.  Probably should
double-check against the GCC 15 branch point to ensure the different behavior
is not specific to the OG15 branch, then git bisect.

[Bug c++/118791] declare variant messes up template instantiation with rvalue arguments

2025-02-07 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118791

Andrew Pinski  changed:

   What|Removed |Added

 Status|RESOLVED|UNCONFIRMED
   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=118530
 Resolution|DUPLICATE   |---

--- Comment #2 from Andrew Pinski  ---
Maybe not a dup. but definitely related.

[Bug c++/118791] declare variant messes up template instantiation with rvalue arguments

2025-02-07 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118791

Andrew Pinski  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |DUPLICATE

--- Comment #1 from Andrew Pinski  ---
Dup.

*** This bug has been marked as a duplicate of bug 118530 ***