public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/94592] New: ICE in non-type template parameter with constexpr constructor
@ 2020-04-14 10:44 pacoarjonilla at yahoo dot es
2020-04-14 10:49 ` [Bug c++/94592] " rguenth at gcc dot gnu.org
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: pacoarjonilla at yahoo dot es @ 2020-04-14 10:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94592
Bug ID: 94592
Summary: ICE in non-type template parameter with constexpr
constructor
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: pacoarjonilla at yahoo dot es
Target Milestone: ---
GCC10 --std=c++20
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
struct A {
constexpr A() {}
};
template <A> struct B { };
template<typename> void bar () {
B<{}> var;
}
void fu() {
bar<int>();
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
meta.cc: In instantiation of ‘struct B<((A)<brace-enclosed initializer
list>())>’:
meta.cc:37:11: required from ‘void bar() [with <template-parameter-1-1> =
int]’
meta.cc:41:14: required from here
meta.cc:34:23: internal compiler error: unexpected expression
‘(A)<brace-enclosed initializer list>()’ of kind implicit_conv_expr
34 | template <A> struct B { };
| ^
0x8c3f37 cxx_eval_constant_expression
/home/paco/git/gcc/gcc/cp/constexpr.c:6301
0x8c4366 cxx_eval_outermost_constant_expr
/home/paco/git/gcc/gcc/cp/constexpr.c:6502
0x8c8654 maybe_constant_value(tree_node*, tree_node*, bool, bool)
/home/paco/git/gcc/gcc/cp/constexpr.c:6774
0x9f860c convert_nontype_argument
/home/paco/git/gcc/gcc/cp/pt.c:7099
0x9f860c convert_template_argument
/home/paco/git/gcc/gcc/cp/pt.c:8331
0x9f9893 coerce_template_parms
/home/paco/git/gcc/gcc/cp/pt.c:8810
0xa1bf61 lookup_template_class_1
/home/paco/git/gcc/gcc/cp/pt.c:9648
0xa1e363 lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*,
int, int)
/home/paco/git/gcc/gcc/cp/pt.c:10020
0xa1e363 tsubst_aggr_type
/home/paco/git/gcc/gcc/cp/pt.c:13301
0xa0e44f tsubst_decl
/home/paco/git/gcc/gcc/cp/pt.c:14294
0xa3079d instantiate_class_template_1
/home/paco/git/gcc/gcc/cp/pt.c:11748
0xa31ab2 instantiate_class_template(tree_node*)
/home/paco/git/gcc/gcc/cp/pt.c:12007
0xa77ff9 complete_type(tree_node*)
/home/paco/git/gcc/gcc/cp/typeck.c:137
0xa0e70b tsubst_decl
/home/paco/git/gcc/gcc/cp/pt.c:14415
0xa063e0 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
/home/paco/git/gcc/gcc/cp/pt.c:17768
0xa0449e tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
/home/paco/git/gcc/gcc/cp/pt.c:17985
0xa01733 instantiate_decl(tree_node*, bool, bool)
/home/paco/git/gcc/gcc/cp/pt.c:25509
0xa31d7b instantiate_pending_templates(int)
/home/paco/git/gcc/gcc/cp/pt.c:25625
0x93b9f3 c_parse_final_cleanups()
/home/paco/git/gcc/gcc/cp/decl2.c:4874
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/94592] ICE in non-type template parameter with constexpr constructor
2020-04-14 10:44 [Bug c++/94592] New: ICE in non-type template parameter with constexpr constructor pacoarjonilla at yahoo dot es
@ 2020-04-14 10:49 ` rguenth at gcc dot gnu.org
2020-04-14 11:16 ` marxin at gcc dot gnu.org
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-04-14 10:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94592
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |ice-on-valid-code
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Huh, constexprs are valid template parameters?
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/94592] ICE in non-type template parameter with constexpr constructor
2020-04-14 10:44 [Bug c++/94592] New: ICE in non-type template parameter with constexpr constructor pacoarjonilla at yahoo dot es
2020-04-14 10:49 ` [Bug c++/94592] " rguenth at gcc dot gnu.org
@ 2020-04-14 11:16 ` marxin at gcc dot gnu.org
2020-04-14 11:41 ` pacoarjonilla at yahoo dot es
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-04-14 11:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94592
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |marxin at gcc dot gnu.org
Keywords|ice-on-valid-code |ice-on-invalid-code
--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
Both clang and ICC reject that. So I bet it's an invalid code.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/94592] ICE in non-type template parameter with constexpr constructor
2020-04-14 10:44 [Bug c++/94592] New: ICE in non-type template parameter with constexpr constructor pacoarjonilla at yahoo dot es
2020-04-14 10:49 ` [Bug c++/94592] " rguenth at gcc dot gnu.org
2020-04-14 11:16 ` marxin at gcc dot gnu.org
@ 2020-04-14 11:41 ` pacoarjonilla at yahoo dot es
2020-04-14 14:32 ` mpolacek at gcc dot gnu.org
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pacoarjonilla at yahoo dot es @ 2020-04-14 11:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94592
Paco Arjonilla <pacoarjonilla at yahoo dot es> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords|ice-on-invalid-code |ice-on-valid-code
--- Comment #3 from Paco Arjonilla <pacoarjonilla at yahoo dot es> ---
It should be valid code.
https://wg21.link/P0732R2
The reason why other compilers reject it is because they have not implemented
it yet.
https://en.cppreference.com/w/cpp/compiler_support
Class types in non-type template parameters (Around halfway of C++20 language
features)
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/94592] ICE in non-type template parameter with constexpr constructor
2020-04-14 10:44 [Bug c++/94592] New: ICE in non-type template parameter with constexpr constructor pacoarjonilla at yahoo dot es
` (2 preceding siblings ...)
2020-04-14 11:41 ` pacoarjonilla at yahoo dot es
@ 2020-04-14 14:32 ` mpolacek at gcc dot gnu.org
2020-04-14 16:29 ` mpolacek at gcc dot gnu.org
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-04-14 14:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94592
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2020-04-14
Ever confirmed|0 |1
Target Milestone|--- |10.0
Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org
Priority|P3 |P1
Status|UNCONFIRMED |ASSIGNED
CC| |mpolacek at gcc dot gnu.org
--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Started with r10-7096-gd417b4f5414d9076300ab41974a14424f722688c so mine.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/94592] ICE in non-type template parameter with constexpr constructor
2020-04-14 10:44 [Bug c++/94592] New: ICE in non-type template parameter with constexpr constructor pacoarjonilla at yahoo dot es
` (3 preceding siblings ...)
2020-04-14 14:32 ` mpolacek at gcc dot gnu.org
@ 2020-04-14 16:29 ` mpolacek at gcc dot gnu.org
2020-04-14 16:38 ` pacoarjonilla at yahoo dot es
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-04-14 16:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94592
--- Comment #5 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
{} as a template argument is currently only supported by GCC as an extension,
but I raised this on the core C++ list and it seems that the the conclusion is
that we want this to work, though there's no CWG for it yet.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/94592] ICE in non-type template parameter with constexpr constructor
2020-04-14 10:44 [Bug c++/94592] New: ICE in non-type template parameter with constexpr constructor pacoarjonilla at yahoo dot es
` (4 preceding siblings ...)
2020-04-14 16:29 ` mpolacek at gcc dot gnu.org
@ 2020-04-14 16:38 ` pacoarjonilla at yahoo dot es
2020-04-15 17:57 ` [Bug c++/94592] [10 Regression] " mpolacek at gcc dot gnu.org
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pacoarjonilla at yahoo dot es @ 2020-04-14 16:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94592
--- Comment #6 from Paco Arjonilla <pacoarjonilla at yahoo dot es> ---
Thanks for supporting this feature. I think it is one of the core features that
modern C++ should have.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/94592] [10 Regression] ICE in non-type template parameter with constexpr constructor
2020-04-14 10:44 [Bug c++/94592] New: ICE in non-type template parameter with constexpr constructor pacoarjonilla at yahoo dot es
` (5 preceding siblings ...)
2020-04-14 16:38 ` pacoarjonilla at yahoo dot es
@ 2020-04-15 17:57 ` mpolacek at gcc dot gnu.org
2020-04-18 3:43 ` mpolacek at gcc dot gnu.org
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-04-15 17:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94592
--- Comment #7 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Another problematical testcase:
struct A {
int i;
constexpr A(int n) : i(n) {}
};
template <A a> struct B { int i; constexpr B() : i(a.i) { } };
template<typename> void bar () {
B<{1}> var;
}
void fu() {
bar<int>();
}
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/94592] [10 Regression] ICE in non-type template parameter with constexpr constructor
2020-04-14 10:44 [Bug c++/94592] New: ICE in non-type template parameter with constexpr constructor pacoarjonilla at yahoo dot es
` (6 preceding siblings ...)
2020-04-15 17:57 ` [Bug c++/94592] [10 Regression] " mpolacek at gcc dot gnu.org
@ 2020-04-18 3:43 ` mpolacek at gcc dot gnu.org
2020-04-20 13:57 ` rguenth at gcc dot gnu.org
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-04-18 3:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94592
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch
--- Comment #8 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Patch posted: https://gcc.gnu.org/pipermail/gcc-patches/2020-April/544068.html
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/94592] [10 Regression] ICE in non-type template parameter with constexpr constructor
2020-04-14 10:44 [Bug c++/94592] New: ICE in non-type template parameter with constexpr constructor pacoarjonilla at yahoo dot es
` (7 preceding siblings ...)
2020-04-18 3:43 ` mpolacek at gcc dot gnu.org
@ 2020-04-20 13:57 ` rguenth at gcc dot gnu.org
2020-04-20 23:55 ` cvs-commit at gcc dot gnu.org
2020-04-20 23:55 ` mpolacek at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-04-20 13:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94592
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work| |9.3.0
--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
Indeed works with GCC 9.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/94592] [10 Regression] ICE in non-type template parameter with constexpr constructor
2020-04-14 10:44 [Bug c++/94592] New: ICE in non-type template parameter with constexpr constructor pacoarjonilla at yahoo dot es
` (8 preceding siblings ...)
2020-04-20 13:57 ` rguenth at gcc dot gnu.org
@ 2020-04-20 23:55 ` cvs-commit at gcc dot gnu.org
2020-04-20 23:55 ` mpolacek at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-04-20 23:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94592
--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:
https://gcc.gnu.org/g:d419e176d74162af6513be0b3bc1031726543993
commit r10-7836-gd419e176d74162af6513be0b3bc1031726543993
Author: Marek Polacek <polacek@redhat.com>
Date: Fri Apr 17 15:47:15 2020 -0400
c++: Fix ICE with { } as template argument [PR94592]
As an extension (there should be a CWG about this though), we support
braced-init-list as a template argument, but convert_nontype_argument
had trouble digesting them. We ICEd because of the double coercion we
perform for template arguments: convert_nontype_argument called from
finish_template_type got a { }, and since a class type was involved and
we were in a template, convert_like created an IMPLICIT_CONV_EXPR. Then
the second conversion of the same argument crashed in constexpr.c
because the IMPLICIT_CONV_EXPR had gotten wrapped in a TARGET_EXPR.
Another issue was that an IMPLICIT_CONV_EXPR leaked to constexpr.c when
building an aggregate init.
We should have instantiated the IMPLICIT_CONV_EXPR in the first call to
convert_nontype_argument, but we didn't, because the call to
is_nondependent_constant_expression returned false because it checks
!BRACE_ENCLOSED_INITIALIZER_P. Then non_dep was false even though the
expression didn't contain anything dependent and we didn't instantiate
it in convert_nontype_argument. To fix this, check
BRACE_ENCLOSED_INITIALIZER_P in cxx_eval_outermost_constant_expr rather
than in is_nondependent_*.
PR c++/94592
* constexpr.c (cxx_eval_outermost_constant_expr): Return when T is
a BRACE_ENCLOSED_INITIALIZER_P.
(is_nondependent_constant_expression): Don't check
BRACE_ENCLOSED_INITIALIZER_P.
(is_nondependent_static_init_expression): Likewise.
* g++.dg/cpp2a/nontype-class34.C: New test.
* g++.dg/cpp2a/nontype-class35.C: New test.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/94592] [10 Regression] ICE in non-type template parameter with constexpr constructor
2020-04-14 10:44 [Bug c++/94592] New: ICE in non-type template parameter with constexpr constructor pacoarjonilla at yahoo dot es
` (9 preceding siblings ...)
2020-04-20 23:55 ` cvs-commit at gcc dot gnu.org
@ 2020-04-20 23:55 ` mpolacek at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-04-20 23:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94592
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #11 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2020-04-20 23:55 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-14 10:44 [Bug c++/94592] New: ICE in non-type template parameter with constexpr constructor pacoarjonilla at yahoo dot es
2020-04-14 10:49 ` [Bug c++/94592] " rguenth at gcc dot gnu.org
2020-04-14 11:16 ` marxin at gcc dot gnu.org
2020-04-14 11:41 ` pacoarjonilla at yahoo dot es
2020-04-14 14:32 ` mpolacek at gcc dot gnu.org
2020-04-14 16:29 ` mpolacek at gcc dot gnu.org
2020-04-14 16:38 ` pacoarjonilla at yahoo dot es
2020-04-15 17:57 ` [Bug c++/94592] [10 Regression] " mpolacek at gcc dot gnu.org
2020-04-18 3:43 ` mpolacek at gcc dot gnu.org
2020-04-20 13:57 ` rguenth at gcc dot gnu.org
2020-04-20 23:55 ` cvs-commit at gcc dot gnu.org
2020-04-20 23:55 ` mpolacek 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).