diff options
author | Patrick Palka <ppalka@redhat.com> | 2020-07-08 14:17:47 -0400 |
---|---|---|
committer | Giuliano Belinassi <giuliano.belinassi@usp.br> | 2020-08-17 13:16:54 -0300 |
commit | 06ffcb774f55359ac8099ac75f5f83a099b6fcce (patch) | |
tree | 9eecc8fd2e49d1232008885ec1fdfe2133728515 /gcc/cp/constexpr.c | |
parent | 1592b5dd1339ff8608ae2c9ad4eadd6f6babfda2 (diff) | |
download | gcc-06ffcb774f55359ac8099ac75f5f83a099b6fcce.zip gcc-06ffcb774f55359ac8099ac75f5f83a099b6fcce.tar.gz gcc-06ffcb774f55359ac8099ac75f5f83a099b6fcce.tar.bz2 |
c++: ICE in is_really_empty_class [PR95497]
We are ICEing in the testcase below because we pass the
yet-uninstantiated class type A<int> of the PARM_DECL b to
is_really_empty_class from is_rvalue_constant_expression when parsing
the requirement t += b.
This patch fixes the ICE by guarding the problematic call to
is_really_empty_class with a COMPLETE_TYPE_P check, which should also
subsume the existing dependent_type_p check.
gcc/cp/ChangeLog:
PR c++/95497
* constexpr.c (potential_constant_expression_1) <case PARM_DECL>:
When processing_template_decl, check COMPLETE_TYPE_P before
calling is_really_empty_class. Don't check dependent_type_p.
gcc/testsuite/ChangeLog:
PR c++/95497
* g++.dg/cpp2a/concepts-pr95497.C: New test.
Diffstat (limited to 'gcc/cp/constexpr.c')
-rw-r--r-- | gcc/cp/constexpr.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index 1939166..ff78ebd 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -7443,7 +7443,7 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now, if (now && want_rval) { tree type = TREE_TYPE (t); - if (dependent_type_p (type) + if ((processing_template_decl && !COMPLETE_TYPE_P (type)) || is_really_empty_class (type, /*ignore_vptr*/false)) /* An empty class has no data to read. */ return true; |