public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/112632] New: [14 Regression] Non-type template parameter created with converting constructor sometimes has original type
@ 2023-11-20 5:08 pinskia at gcc dot gnu.org
2023-11-20 5:08 ` [Bug c++/112632] " pinskia at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-20 5:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112632
Bug ID: 112632
Summary: [14 Regression] Non-type template parameter created
with converting constructor sometimes has original
type
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Keywords: needs-bisection, rejects-valid
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
Take:
```
template<typename T>
inline constexpr bool C = true;
struct n {
constexpr n(int a) : i(a) {}
int i;
};
template<n N>
using get_n_i_type = decltype(N.i);
template<int X>
int f() {
using iii = get_n_i_type<X>;
#if 1 // Change to 0 and this compiles
static_assert(C<iii>);
#endif
return iii{};
}
template int f<3>();
```
This is rejected on the trunk with:
```
<source>: In instantiation of 'int f() [with int X = 3]':
<source>:22:23: required from here
22 | template int f<3>();
| ^
<source>:11:37: error: request for member 'i' in '3', which is of non-class
type 'int'
11 | using get_n_i_type = decltype(N.i);
| ~~^
```
But was accepted in GCC 13. Note the difference between this and PR 112594 is
that C here is declared an `inline constexpr` rather than a concept.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/112632] [14 Regression] Non-type template parameter created with converting constructor sometimes has original type
2023-11-20 5:08 [Bug c++/112632] New: [14 Regression] Non-type template parameter created with converting constructor sometimes has original type pinskia at gcc dot gnu.org
@ 2023-11-20 5:08 ` pinskia at gcc dot gnu.org
2023-11-20 14:32 ` ppalka at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-20 5:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112632
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |14.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/112632] [14 Regression] Non-type template parameter created with converting constructor sometimes has original type
2023-11-20 5:08 [Bug c++/112632] New: [14 Regression] Non-type template parameter created with converting constructor sometimes has original type pinskia at gcc dot gnu.org
2023-11-20 5:08 ` [Bug c++/112632] " pinskia at gcc dot gnu.org
@ 2023-11-20 14:32 ` ppalka at gcc dot gnu.org
2024-01-10 13:45 ` rguenth at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-11-20 14:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112632
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords|needs-bisection |
CC| |ppalka at gcc dot gnu.org
Status|UNCONFIRMED |NEW
Last reconfirmed| |2023-11-20
Ever confirmed|0 |1
--- Comment #1 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Started with r14-2170-g4cf64d9cc2faf4, although that just makes the more
general problem affect variable templates as well.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/112632] [14 Regression] Non-type template parameter created with converting constructor sometimes has original type
2023-11-20 5:08 [Bug c++/112632] New: [14 Regression] Non-type template parameter created with converting constructor sometimes has original type pinskia at gcc dot gnu.org
2023-11-20 5:08 ` [Bug c++/112632] " pinskia at gcc dot gnu.org
2023-11-20 14:32 ` ppalka at gcc dot gnu.org
@ 2024-01-10 13:45 ` rguenth at gcc dot gnu.org
2024-01-17 22:07 ` jason at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-01-10 13:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112632
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/112632] [14 Regression] Non-type template parameter created with converting constructor sometimes has original type
2023-11-20 5:08 [Bug c++/112632] New: [14 Regression] Non-type template parameter created with converting constructor sometimes has original type pinskia at gcc dot gnu.org
` (2 preceding siblings ...)
2024-01-10 13:45 ` rguenth at gcc dot gnu.org
@ 2024-01-17 22:07 ` jason at gcc dot gnu.org
2024-01-19 18:35 ` cvs-commit at gcc dot gnu.org
2024-01-19 18:37 ` jason at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2024-01-17 22:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112632
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |jason at gcc dot gnu.org
CC| |jason at gcc dot gnu.org
Status|NEW |ASSIGNED
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/112632] [14 Regression] Non-type template parameter created with converting constructor sometimes has original type
2023-11-20 5:08 [Bug c++/112632] New: [14 Regression] Non-type template parameter created with converting constructor sometimes has original type pinskia at gcc dot gnu.org
` (3 preceding siblings ...)
2024-01-17 22:07 ` jason at gcc dot gnu.org
@ 2024-01-19 18:35 ` cvs-commit at gcc dot gnu.org
2024-01-19 18:37 ` jason at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-01-19 18:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112632
--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Jason Merrill <jason@gcc.gnu.org>:
https://gcc.gnu.org/g:f1e5bf0d83ee4da81b6317c6d7f1278fe7eaa5a0
commit r14-8291-gf1e5bf0d83ee4da81b6317c6d7f1278fe7eaa5a0
Author: Jason Merrill <jason@redhat.com>
Date: Wed Jan 17 17:29:33 2024 -0500
c++: alias template argument conversion [PR112632]
We've had a problem with lost conversions to template parameter types for a
while now; looking at this PR, it occurred to me that the problem is really
with alias (and concept) templates, since we do substitution of dependent
arguments into them in a way that we don't for other templates. And fixing
that specific problem is a lot simpler than adding IMPLICIT_CONV_EXPR
around
all dependent template arguments the way I gave up on for 111357.
The other part of the fix was changing tsubst_expr to actually call
convert_nontype_argument instead of assuming it will eventually happen.
I waffled about stripping the forced conversion when !force_conv
vs. skipping them in iterative_hash_template_arg and
template_args_equal (like we already do for some other conversions) and
decided to go with the former, but that isn't a strong preference if it
turns out to be somehow problematic.
PR c++/112632
PR c++/112594
PR c++/111357
PR c++/104594
PR c++/67898
gcc/cp/ChangeLog:
* cp-tree.h (IMPLICIT_CONV_EXPR_FORCED): New.
* pt.cc (expand_integer_pack): Remove 111357 workaround.
(maybe_convert_nontype_argument): Add force parm.
(convert_template_argument): Handle alias template args
specially.
(tsubst_expr): Don't ignore IMPLICIT_CONV_EXPR_NONTYPE_ARG.
* error.cc (dump_expr) [CASE_CONVERT]: Handle null optype.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/alias-decl-nontype1.C: New test.
* g++.dg/cpp2a/concepts-narrowing1.C: New test.
* g++.dg/cpp2a/nontype-class63.C: New test.
* g++.dg/cpp2a/nontype-class63a.C: New test.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/112632] [14 Regression] Non-type template parameter created with converting constructor sometimes has original type
2023-11-20 5:08 [Bug c++/112632] New: [14 Regression] Non-type template parameter created with converting constructor sometimes has original type pinskia at gcc dot gnu.org
` (4 preceding siblings ...)
2024-01-19 18:35 ` cvs-commit at gcc dot gnu.org
@ 2024-01-19 18:37 ` jason at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2024-01-19 18:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112632
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for GCC 14.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-01-19 18:37 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-20 5:08 [Bug c++/112632] New: [14 Regression] Non-type template parameter created with converting constructor sometimes has original type pinskia at gcc dot gnu.org
2023-11-20 5:08 ` [Bug c++/112632] " pinskia at gcc dot gnu.org
2023-11-20 14:32 ` ppalka at gcc dot gnu.org
2024-01-10 13:45 ` rguenth at gcc dot gnu.org
2024-01-17 22:07 ` jason at gcc dot gnu.org
2024-01-19 18:35 ` cvs-commit at gcc dot gnu.org
2024-01-19 18:37 ` jason 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).