From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Cc: Jakub Jelinek <jakub@redhat.com>
Subject: [PATCH] tree-optimization/115232 - demangle failure during -Waccess
Date: Mon, 27 May 2024 11:11:43 +0200 (CEST) [thread overview]
Message-ID: <20240527091143.T5LqszJAxJYapA0mn3M6MzMJtkIoMRswIPWi3D5ORJo@z> (raw)
For the following testcase we fail to demangle
_ZZN5OuterIvE6methodIvEEvvQ3cstITL0__EEN5InnernwEm and
_ZZN5OuterIvE6methodIvEEvvQ3cstITL0__EEN5InnerdlEPv and in turn end
up building NULL references. The following puts in a safeguard for
faile demangling into -Waccess.
Bootstrapped and tested on x86_64-unknown-linux-gnu, OK?
Thanks,
Richard.
PR tree-optimization/115232
* gimple-ssa-warn-access.cc (new_delete_mismatch_p): Handle
failure to demangle gracefully.
* g++.dg/pr115232.C: New testcase.
---
gcc/gimple-ssa-warn-access.cc | 2 +-
gcc/testsuite/g++.dg/pr115232.C | 25 +++++++++++++++++++++++++
2 files changed, 26 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/g++.dg/pr115232.C
diff --git a/gcc/gimple-ssa-warn-access.cc b/gcc/gimple-ssa-warn-access.cc
index 0cd5b6d6ef4..61f9f0f3d31 100644
--- a/gcc/gimple-ssa-warn-access.cc
+++ b/gcc/gimple-ssa-warn-access.cc
@@ -1762,7 +1762,7 @@ new_delete_mismatch_p (tree new_decl, tree delete_decl)
void *np = NULL, *dp = NULL;
demangle_component *ndc = cplus_demangle_v3_components (new_str, 0, &np);
demangle_component *ddc = cplus_demangle_v3_components (del_str, 0, &dp);
- bool mismatch = new_delete_mismatch_p (*ndc, *ddc);
+ bool mismatch = ndc && ddc && new_delete_mismatch_p (*ndc, *ddc);
free (np);
free (dp);
return mismatch;
diff --git a/gcc/testsuite/g++.dg/pr115232.C b/gcc/testsuite/g++.dg/pr115232.C
new file mode 100644
index 00000000000..e1d96d8f899
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr115232.C
@@ -0,0 +1,25 @@
+// { dg-do compile }
+// { dg-require-effective-target c++20 }
+
+using size_t = decltype(sizeof(0));
+template <class U>
+static constexpr bool cst = true;
+template<class T>
+struct Outer
+{
+ Outer();
+ template <class U> void method() requires cst<U>
+ {
+ struct Inner
+ {
+ static void* operator new(size_t){return new char;}
+ static void operator delete(void*){}
+ Outer<void> t;
+ };
+ new Inner;
+ }
+};
+void f()
+{
+ Outer<void>{}.method<void>();
+}
--
2.35.3
next reply other threads:[~2024-05-27 9:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-27 9:11 Richard Biener [this message]
[not found] <64354.124052705114500359@us-mta-591.us.mimecast.lan>
2024-05-27 9:15 ` Jakub Jelinek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240527091143.T5LqszJAxJYapA0mn3M6MzMJtkIoMRswIPWi3D5ORJo@z \
--to=rguenther@suse.de \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).