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

* [Bug c++/98824] [C++-20] function template non-type-class-arg deduction fails with a reason that looks bogus
  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 ` dimitri.gorokhovik at free dot fr
  2021-08-17  9:24 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: dimitri.gorokhovik at free dot fr @ 2021-01-27 15:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Dimitri Gorokhovik <dimitri.gorokhovik at free dot fr> ---
It doesn't seem to contradict N4868 :-(

Modifying the code slightly (adding refs, splitting deduction across two fn
templates) didn't show any other differences from clang: all other modification
either both pass or both fail with the equivalent messages ("'i' cannot be
deduced"). This is the only one.

clang version:
Ubuntu clang version
12.0.0-++20201102052620+327bf5c2d91-1~exp1~20201102163303.210
Target: x86_64-pc-linux-gnu

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

* [Bug c++/98824] [C++-20] function template non-type-class-arg deduction fails with a reason that looks bogus
  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
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-17  9:24 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |rejects-valid
   Last reconfirmed|                            |2021-08-17

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

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

* [Bug c++/98824] [C++-20] function template non-type-class-arg deduction fails with a reason that looks bogus
  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
  3 siblings, 0 replies; 5+ messages in thread
From: bernie at codewiz dot org @ 2022-01-18  5:50 UTC (permalink / raw)
  To: gcc-bugs

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

Bernie Innocenti <bernie at codewiz dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bernie at codewiz dot org

--- Comment #3 from Bernie Innocenti <bernie at codewiz dot org> ---
Assuming this is the same bug, it's still present in g++ 12 as well as trunk:
https://godbolt.org/z/6r3bc3j15

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

* [Bug c++/98824] [C++-20] function template non-type-class-arg deduction fails with a reason that looks bogus
  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
                   ` (2 preceding siblings ...)
  2022-01-18  5:50 ` bernie at codewiz dot org
@ 2022-01-18  5:51 ` bernie at codewiz dot org
  3 siblings, 0 replies; 5+ messages in thread
From: bernie at codewiz dot org @ 2022-01-18  5:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Bernie Innocenti <bernie at codewiz dot org> ---
Are there any known workarounds?

^ 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).