public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] c++: fix ICE with is_really_empty_class [PR110106]
@ 2023-07-18 21:14 Marek Polacek
  2023-07-19 14:11 ` Patrick Palka
  0 siblings, 1 reply; 12+ messages in thread
From: Marek Polacek @ 2023-07-18 21:14 UTC (permalink / raw)
  To: GCC Patches, Jason Merrill

Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk and branches?

-- >8 --

is_really_empty_class is liable to crash when it gets an incomplete
or dependent type.  Since r11-557, we pass the yet-uninstantiated
class type S<0> of the PARM_DECL s to is_really_empty_class -- because
of the potential_rvalue_constant_expression -> is_rvalue_constant_expression
change in cp_parser_constant_expression.  Here we're not parsing
a template so we did not check COMPLETE_TYPE_P as we should.

	PR c++/110106

gcc/cp/ChangeLog:

	* constexpr.cc (potential_constant_expression_1): Check COMPLETE_TYPE_P
	even when !processing_template_decl.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/noexcept80.C: New test.
---
 gcc/cp/constexpr.cc                     |  2 +-
 gcc/testsuite/g++.dg/cpp0x/noexcept80.C | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp0x/noexcept80.C

diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc
index 6e8f1c2b61e..1f59c5472fb 100644
--- a/gcc/cp/constexpr.cc
+++ b/gcc/cp/constexpr.cc
@@ -9116,7 +9116,7 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now,
       if (now && want_rval)
 	{
 	  tree type = TREE_TYPE (t);
-	  if ((processing_template_decl && !COMPLETE_TYPE_P (type))
+	  if (!COMPLETE_TYPE_P (type)
 	      || dependent_type_p (type)
 	      || is_really_empty_class (type, /*ignore_vptr*/false))
 	    /* An empty class has no data to read.  */
diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept80.C b/gcc/testsuite/g++.dg/cpp0x/noexcept80.C
new file mode 100644
index 00000000000..3e90af747e2
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/noexcept80.C
@@ -0,0 +1,12 @@
+// PR c++/110106
+// { dg-do compile { target c++11 } }
+
+template<int> struct S
+{
+};
+
+struct G {
+  G(S<0>);
+};
+
+void y(S<0> s) noexcept(noexcept(G{s}));

base-commit: fca089e8a47314a40ad93527ba9f9d0d374b3afb
-- 
2.41.0


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

end of thread, other threads:[~2023-07-26  2:03 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-18 21:14 [PATCH] c++: fix ICE with is_really_empty_class [PR110106] Marek Polacek
2023-07-19 14:11 ` Patrick Palka
2023-07-20 18:13   ` Marek Polacek
2023-07-20 18:37     ` Jason Merrill
2023-07-20 19:51       ` Marek Polacek
2023-07-20 21:58         ` Marek Polacek
2023-07-21 17:44           ` Jason Merrill
2023-07-25 19:59             ` Marek Polacek
2023-07-25 20:24               ` Jason Merrill
2023-07-25 20:30                 ` Marek Polacek
2023-07-26  2:03                   ` Jason Merrill
2023-07-21 17:44         ` Jason Merrill

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