public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/105110] New: NTTP type deduction fails when dependent of previous NTTPs
@ 2022-03-30 16:04 j.galecki11 at gmail dot com
2022-03-30 21:21 ` [Bug c++/105110] " ppalka at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: j.galecki11 at gmail dot com @ 2022-03-30 16:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105110
Bug ID: 105110
Summary: NTTP type deduction fails when dependent of previous
NTTPs
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: j.galecki11 at gmail dot com
Target Milestone: ---
Consider the following minimal example:
```
template <int>
struct S {};
template <auto>
struct V {};
template <int I, S<I> s>
void foo(V<s>) {}
void bar() {
constexpr S<1> s;
foo(V<s>{});
}
```
CE link for the reader's convenience: https://godbolt.org/z/1cYK9s1Ta
GCC fails to compile this (consistent across versions), complaining about
cv-qualifier mismatch, which seems wholly irrelevant. Clang compiles without
warnings.
The problem is that when instantiating a function parametrized with a NTTP, GCC
fails to deduce the type of the NTTP parameter based on the other function
parameters. This causes problems with passing around constexpr values, as shown
in the following second example: https://godbolt.org/z/3Tnjx1Wxb (again, Clang
compiles and executes as intended).
As I cannot quite figure out whether the standard requires the deduction
described above to be possible, I see 2 possibilities:
1) This is simply a bug in GCC.
2) GCC is correct in refusing to compile the provided examples (Clang is
wrong). In this case, the emitted error should probably better describe the
problem.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/105110] NTTP type deduction fails when dependent of previous NTTPs
2022-03-30 16:04 [Bug c++/105110] New: NTTP type deduction fails when dependent of previous NTTPs j.galecki11 at gmail dot com
@ 2022-03-30 21:21 ` ppalka at gcc dot gnu.org
2022-04-01 18:57 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-03-30 21:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105110
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Keywords| |rejects-valid
CC| |ppalka at gcc dot gnu.org
Last reconfirmed| |2022-03-30
Assignee|unassigned at gcc dot gnu.org |ppalka at gcc dot gnu.org
Status|UNCONFIRMED |ASSIGNED
--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Confirmed, seems like a bug indeed.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/105110] NTTP type deduction fails when dependent of previous NTTPs
2022-03-30 16:04 [Bug c++/105110] New: NTTP type deduction fails when dependent of previous NTTPs j.galecki11 at gmail dot com
2022-03-30 21:21 ` [Bug c++/105110] " ppalka at gcc dot gnu.org
@ 2022-04-01 18:57 ` cvs-commit at gcc dot gnu.org
2022-04-01 18:59 ` ppalka at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-04-01 18:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105110
--- 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:95533fe4f014c10dd18de649927668aba6117daf
commit r12-7966-g95533fe4f014c10dd18de649927668aba6117daf
Author: Patrick Palka <ppalka@redhat.com>
Date: Fri Apr 1 14:56:20 2022 -0400
c++: deducing from class type of NTTP [PR105110]
Here when attempting to deduce T in the NTTP type A<T> from the argument
type 'const A<int>', we give up due to the const:
types âA<T>â and âconst A<int>â have incompatible cv-qualifiers
But since the type of an NTTP cannot be cv-qualified, it seems natural
to ignore cv-qualifiers on the argument type before attempting to unify
the two types.
PR c++/105110
gcc/cp/ChangeLog:
* pt.cc (unify) <case TEMPLATE_PARM_INDEX>: Drop cv-quals from
the argument type of an NTTP before deducing from it.
gcc/testsuite/ChangeLog:
* g++.dg/cpp2a/nontype-class52.C: New test.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/105110] NTTP type deduction fails when dependent of previous NTTPs
2022-03-30 16:04 [Bug c++/105110] New: NTTP type deduction fails when dependent of previous NTTPs j.galecki11 at gmail dot com
2022-03-30 21:21 ` [Bug c++/105110] " ppalka at gcc dot gnu.org
2022-04-01 18:57 ` cvs-commit at gcc dot gnu.org
@ 2022-04-01 18:59 ` ppalka at gcc dot gnu.org
2022-04-01 19:13 ` j.galecki11 at gmail dot com
2022-06-02 18:06 ` ppalka at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-04-01 18:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105110
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Target Milestone|--- |12.0
Status|ASSIGNED |RESOLVED
--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 12, thanks for the bug report.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/105110] NTTP type deduction fails when dependent of previous NTTPs
2022-03-30 16:04 [Bug c++/105110] New: NTTP type deduction fails when dependent of previous NTTPs j.galecki11 at gmail dot com
` (2 preceding siblings ...)
2022-04-01 18:59 ` ppalka at gcc dot gnu.org
@ 2022-04-01 19:13 ` j.galecki11 at gmail dot com
2022-06-02 18:06 ` ppalka at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: j.galecki11 at gmail dot com @ 2022-04-01 19:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105110
--- Comment #4 from Jakub Gałecki <j.galecki11 at gmail dot com> ---
Awesome! Happy to be of use.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/105110] NTTP type deduction fails when dependent of previous NTTPs
2022-03-30 16:04 [Bug c++/105110] New: NTTP type deduction fails when dependent of previous NTTPs j.galecki11 at gmail dot com
` (3 preceding siblings ...)
2022-04-01 19:13 ` j.galecki11 at gmail dot com
@ 2022-06-02 18:06 ` ppalka at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-06-02 18:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105110
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |davveston at gmail dot com
--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> ---
*** Bug 99699 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-06-02 18:06 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-30 16:04 [Bug c++/105110] New: NTTP type deduction fails when dependent of previous NTTPs j.galecki11 at gmail dot com
2022-03-30 21:21 ` [Bug c++/105110] " ppalka at gcc dot gnu.org
2022-04-01 18:57 ` cvs-commit at gcc dot gnu.org
2022-04-01 18:59 ` ppalka at gcc dot gnu.org
2022-04-01 19:13 ` j.galecki11 at gmail dot com
2022-06-02 18:06 ` 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).