public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/104802] New: Non-type template parameter of reference type disallowed under certain conditions
@ 2022-03-05 23:47 sneves at dei dot uc.pt
  2022-03-09 16:53 ` [Bug c++/104802] " ppalka at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: sneves at dei dot uc.pt @ 2022-03-05 23:47 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 104802
           Summary: Non-type template parameter of reference type
                    disallowed under certain conditions
           Product: gcc
           Version: 11.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sneves at dei dot uc.pt
  Target Milestone: ---

Minimal (C++17 and 20) example:

  template<auto const& ... Args>
  struct S {
    template<typename=void>
    void operator()() const {}
  };

  struct weird_ {
    int operator&() const { return 123; }
  } const weird {};

  auto f() {
    S<weird> s {};
    s();
  }

This fails with the error:

  error: '&(const weird_&)weird.weird_::operator&()' is not a valid template
argument of type 'const weird_&' because '(const
weird_&)weird.weird_::operator&()' is not a variable

Now, if either one of

  - template<typename=void> is commented out, i.e., the called function is no
longer a template;

  - `weird` has the `operator&` removed;

The code compiles without any issues.

As far as I can tell this example is not violating any of the constraints the
standard puts on lvalue reference parameters, and both Clang and MSVC accept
it.

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

* [Bug c++/104802] Non-type template parameter of reference type disallowed under certain conditions
  2022-03-05 23:47 [Bug c++/104802] New: Non-type template parameter of reference type disallowed under certain conditions sneves at dei dot uc.pt
@ 2022-03-09 16:53 ` ppalka at gcc dot gnu.org
  2023-11-16 15:50 ` cvs-commit at gcc dot gnu.org
  2023-11-16 15:51 ` ppalka at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-03-09 16:53 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=98614
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
      Known to fail|                            |11.2.0
   Last reconfirmed|                            |2022-03-09
           Keywords|                            |rejects-valid
                 CC|                            |jason at gcc dot gnu.org,
                   |                            |ppalka at gcc dot gnu.org
      Known to work|                            |12.0

--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
This appears to have been fixed on trunk by r12-1403-gc4e50e500da7692a
interestingly enough (as with PR98614).

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

* [Bug c++/104802] Non-type template parameter of reference type disallowed under certain conditions
  2022-03-05 23:47 [Bug c++/104802] New: Non-type template parameter of reference type disallowed under certain conditions sneves at dei dot uc.pt
  2022-03-09 16:53 ` [Bug c++/104802] " ppalka at gcc dot gnu.org
@ 2023-11-16 15:50 ` cvs-commit at gcc dot gnu.org
  2023-11-16 15:51 ` ppalka at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-11-16 15:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:063d987af0e7a8329559fb116337bdb8ab20d8eb

commit r14-5532-g063d987af0e7a8329559fb116337bdb8ab20d8eb
Author: Patrick Palka <ppalka@redhat.com>
Date:   Thu Nov 16 10:49:17 2023 -0500

    c++: add fixed testcases [PR98614, PR104802]

    Both of these PRs are fixed by r12-1403-gc4e50e500da7692a.

            PR c++/98614
            PR c++/104802

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp1z/nontype-auto22.C: New test.
            * g++.dg/cpp2a/concepts-partial-spec14.C: New test.

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

* [Bug c++/104802] Non-type template parameter of reference type disallowed under certain conditions
  2022-03-05 23:47 [Bug c++/104802] New: Non-type template parameter of reference type disallowed under certain conditions sneves at dei dot uc.pt
  2022-03-09 16:53 ` [Bug c++/104802] " ppalka at gcc dot gnu.org
  2023-11-16 15:50 ` cvs-commit at gcc dot gnu.org
@ 2023-11-16 15:51 ` ppalka at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-11-16 15:51 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |12.0

--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed since GCC 12

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

end of thread, other threads:[~2023-11-16 15:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-05 23:47 [Bug c++/104802] New: Non-type template parameter of reference type disallowed under certain conditions sneves at dei dot uc.pt
2022-03-09 16:53 ` [Bug c++/104802] " ppalka at gcc dot gnu.org
2023-11-16 15:50 ` cvs-commit at gcc dot gnu.org
2023-11-16 15:51 ` 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).