public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/110291] New: [11.1 Regression] constraint on friend operator template causes bizarre duplication of RHS template parameter that is passed to the requires expression
@ 2023-06-16 20:36 waffl3x at protonmail dot com
  2023-06-16 20:43 ` [Bug c++/110291] " waffl3x at protonmail dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: waffl3x at protonmail dot com @ 2023-06-16 20:36 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110291

            Bug ID: 110291
           Summary: [11.1 Regression] constraint on friend operator
                    template causes bizarre duplication of RHS template
                    parameter that is passed to the requires expression
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: waffl3x at protonmail dot com
  Target Milestone: ---

template<typename L, typename R>
struct fn { using type = decltype(L{} + R{}); };

struct no_self {};
no_self operator+(int, no_self);

void operator+(no_self, no_self) = delete;

template<typename T>
struct expr {
    template<typename U>
        requires requires {typename fn<T, U>::type;}
    friend void operator/(expr<T>, expr<U>);
};

using X = decltype(expr<int>{} / expr<no_self>{});

https://godbolt.org/z/on1KdfY9T
`error: use of deleted function 'void operator+(no_self, no_self)'`
Working in GCC 9.5 and GCC 10.4, broken in 11.1 and onward. Not too much of a
monologue from me this time, I couldn't beat much interesting information out
of it. Best I can tell is it's definitely related to the constraint (note that
separating it into a concept does not fix the issue), and it being a friend
operator is relevant. I am pretty sure the addition operator overload is not
related, it's just related to what I was doing when I encountered the bug. I'm
pretty sure there is another layer that could be peeled off here, but it
started to hurt my head and for a small bug I think this should be good enough.

It almost seems like it's caching U and preemptively evaluating the RHS as a
LHS with the cached U type. I wanted to confirm this somehow, but like I said,
it just wasn't cooperating. My experimenting was just resulting in much much
more complicated examples,so I decided to just call it here.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/110291] [11.1 Regression] constraint on friend operator template causes bizarre duplication of RHS template parameter that is passed to the requires expression
  2023-06-16 20:36 [Bug c++/110291] New: [11.1 Regression] constraint on friend operator template causes bizarre duplication of RHS template parameter that is passed to the requires expression waffl3x at protonmail dot com
@ 2023-06-16 20:43 ` waffl3x at protonmail dot com
  2023-06-19  6:53 ` [Bug c++/110291] [11/12/13/14 " rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: waffl3x at protonmail dot com @ 2023-06-16 20:43 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110291

--- Comment #1 from waffl3x <waffl3x at protonmail dot com> ---
I opened Bug 110006 and forgot to check before submitting, looking over at it,
I'm pretty sure it's the same bug, and if not, then probably related.
https://godbolt.org/z/7zoWfG4Ws I checked their reproduction and sure enough,
it's also an 11.1 regression just like this one, so it is almost certainly the
same. So this should probably be marked as a duplicate of it? I'm not really
sure what the protocol for that is though so I'll leave it to someone else.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/110291] [11/12/13/14 Regression] constraint on friend operator template causes bizarre duplication of RHS template parameter that is passed to the requires expression
  2023-06-16 20:36 [Bug c++/110291] New: [11.1 Regression] constraint on friend operator template causes bizarre duplication of RHS template parameter that is passed to the requires expression waffl3x at protonmail dot com
  2023-06-16 20:43 ` [Bug c++/110291] " waffl3x at protonmail dot com
@ 2023-06-19  6:53 ` rguenth at gcc dot gnu.org
  2023-07-10  6:18 ` pinskia at gcc dot gnu.org
  2023-08-01 18:16 ` ppalka at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-06-19  6:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110291

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |11.5
            Summary|[11.1 Regression]           |[11/12/13/14 Regression]
                   |constraint on friend        |constraint on friend
                   |operator template causes    |operator template causes
                   |bizarre duplication of RHS  |bizarre duplication of RHS
                   |template parameter that is  |template parameter that is
                   |passed to the requires      |passed to the requires
                   |expression                  |expression
           Keywords|                            |rejects-valid

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/110291] [11/12/13/14 Regression] constraint on friend operator template causes bizarre duplication of RHS template parameter that is passed to the requires expression
  2023-06-16 20:36 [Bug c++/110291] New: [11.1 Regression] constraint on friend operator template causes bizarre duplication of RHS template parameter that is passed to the requires expression waffl3x at protonmail dot com
  2023-06-16 20:43 ` [Bug c++/110291] " waffl3x at protonmail dot com
  2023-06-19  6:53 ` [Bug c++/110291] [11/12/13/14 " rguenth at gcc dot gnu.org
@ 2023-07-10  6:18 ` pinskia at gcc dot gnu.org
  2023-08-01 18:16 ` ppalka at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-07-10  6:18 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110291

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |needs-bisection
   Last reconfirmed|                            |2023-07-10
      Known to work|                            |10.1.0, 10.4.0
     Ever confirmed|0                           |1
      Known to fail|                            |11.1.0

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/110291] [11/12/13/14 Regression] constraint on friend operator template causes bizarre duplication of RHS template parameter that is passed to the requires expression
  2023-06-16 20:36 [Bug c++/110291] New: [11.1 Regression] constraint on friend operator template causes bizarre duplication of RHS template parameter that is passed to the requires expression waffl3x at protonmail dot com
                   ` (2 preceding siblings ...)
  2023-07-10  6:18 ` pinskia at gcc dot gnu.org
@ 2023-08-01 18:16 ` ppalka at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-08-01 18:16 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110291

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |ppalka at gcc dot gnu.org
         Resolution|---                         |DUPLICATE
           Keywords|needs-bisection             |

--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Started with r11-2774.

This seems like an unexpected consequence of CWG2369: during overload
resolution for 'expr<int>{} / expr<no_self>{}' we have two interesting
candidates

expr<int>::operator/(expr<int>, expr<U>) [with U=no_self]          // #1
expr<no_self>::operator/(expr<no_self>, expr<U>) [with U=no_self]  // #2

Before CWG2369 we would discard #2 due to expr<int> not being convertible to
expr<no_self>, and we don't need to check #2's constraints.  But CWG2369 makes
us check constraints before checking non-dependent conversions, and it's during
constraint checking for #2 that we instantiate fn<no_self, no_self> which
ultimately leads to the hard error :( Only GCC implements CWG2369 as far as I
know.

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-08-01 18:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-16 20:36 [Bug c++/110291] New: [11.1 Regression] constraint on friend operator template causes bizarre duplication of RHS template parameter that is passed to the requires expression waffl3x at protonmail dot com
2023-06-16 20:43 ` [Bug c++/110291] " waffl3x at protonmail dot com
2023-06-19  6:53 ` [Bug c++/110291] [11/12/13/14 " rguenth at gcc dot gnu.org
2023-07-10  6:18 ` pinskia at gcc dot gnu.org
2023-08-01 18:16 ` ppalka at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).