public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/98824] New: [C++-20] function template non-type-class-arg deduction fails with a reason that looks bogus
@ 2021-01-25 16:18 dimitri.gorokhovik at free dot fr
  2021-01-27 15:33 ` [Bug c++/98824] " dimitri.gorokhovik at free dot fr
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: dimitri.gorokhovik at free dot fr @ 2021-01-25 16:18 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 98824
           Summary: [C++-20] function template non-type-class-arg
                    deduction fails with a reason that looks bogus
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dimitri.gorokhovik at free dot fr
  Target Milestone: ---

The code:

template <auto> struct a {};
template <int i, a <i> v> constexpr auto f (a <v>) { return true; };

constexpr a <1> b;
auto const p = f (a <b> {});


when compiled with 'g++ -std=c++20 -c bug-14.cpp' (g++ (GCC) 11.0.0 20210123
(experimental)), produces:


bug-14.cpp:5:27: error: no matching function for call to ‘f(a<a<1>()>)’
    5 | auto const p = f (a <b> {});
      |                           ^
bug-14.cpp:2:42: note: candidate: ‘template<int i, a<i> v> constexpr auto
f(a<((const a<i>)v)>)’
    2 | template <int i, a <i> v> constexpr auto f (a <v>) { return true; };
      |                                          ^
bug-14.cpp:2:42: note:   template argument deduction/substitution failed:
bug-14.cpp:5:27: note:   types ‘a<i>’ and ‘const a<1>’ have incompatible
cv-qualifiers
    5 | auto const p = f (a <b> {});


clang-12 seems to accept it (hits a non-implemented feature in a subsequent
pass). 


The diagnostics looks confusing/misleading:
-- compiler is aware of the constness of 'a <i>' -- see the signature of f() in
the note for line 2. And then it seemingly removes 'const' from 'const a <i>',
maybe expecting a certain strictness level in 'unify()'. However, unify() is
called with strict=UNIFY_ALLOW_NONE.

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

end of thread, other threads:[~2022-01-18  5:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-25 16:18 [Bug c++/98824] New: [C++-20] function template non-type-class-arg deduction fails with a reason that looks bogus dimitri.gorokhovik at free dot fr
2021-01-27 15:33 ` [Bug c++/98824] " dimitri.gorokhovik at free dot fr
2021-08-17  9:24 ` pinskia at gcc dot gnu.org
2022-01-18  5:50 ` bernie at codewiz dot org
2022-01-18  5:51 ` bernie at codewiz dot 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).