public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/109001] New: “no declaration matches” for complicated non-type template parameters
@ 2023-03-03  4:39 headch at gmail dot com
  2023-03-03 14:12 ` [Bug c++/109001] " ppalka at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: headch at gmail dot com @ 2023-03-03  4:39 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109001
           Summary: “no declaration matches” for complicated non-type
                    template parameters
           Product: gcc
           Version: 12.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: headch at gmail dot com
  Target Milestone: ---

I’m reasonably certain (but not completely) that this is valid code:

#include <algorithm>
#include <cstddef>

template<size_t x>
class C {
public:
template<size_t y>
C<std::max(x, y)> set();
};

template<size_t x>
template<size_t y>
C<std::max(x, y)> C<x>::set() {
return {};
}

however, GCC rejects it with “error: no declaration matches ‘C<std::max<long
unsigned int>(x, y)> C<x>::set()’” on the out-of-body function definition. This
is accepted in GCC 11.3, as well as the latest versions of Clang and MSVC on
gcc.godbolt.org. Interestingly, GCC 12 also accepts the code if I change the
function definition (just the definition, not the in-body declaration) to use
trailing-return-type syntax:

#include <algorithm>
#include <cstddef>

template<size_t x>
class C {
public:
template<size_t y>
C<std::max(x, y)> set();
};

template<size_t x>
template<size_t y>
auto C<x>::set() -> C<std::max(x, y)> {
return {};
}

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

* [Bug c++/109001] “no declaration matches” for complicated non-type template parameters
  2023-03-03  4:39 [Bug c++/109001] New: “no declaration matches” for complicated non-type template parameters headch at gmail dot com
@ 2023-03-03 14:12 ` ppalka at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-03-03 14:12 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE
                 CC|                            |ppalka at gcc dot gnu.org

--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Thanks for the bug report, this appears to be a dup of PR107461 which has been
fixed for GCC 12.3 and 13.

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

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

end of thread, other threads:[~2023-03-03 14:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-03  4:39 [Bug c++/109001] New: “no declaration matches” for complicated non-type template parameters headch at gmail dot com
2023-03-03 14:12 ` [Bug c++/109001] " 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).