* [PATCH] tree-optimization/115232 - demangle failure during -Waccess
@ 2024-05-27 9:11 Richard Biener
0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2024-05-27 9:11 UTC (permalink / raw)
To: gcc-patches; +Cc: Jakub Jelinek
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
^ permalink raw reply [flat|nested] 2+ messages in thread
[parent not found: <64354.124052705114500359@us-mta-591.us.mimecast.lan>]
* Re: [PATCH] tree-optimization/115232 - demangle failure during -Waccess
[not found] <64354.124052705114500359@us-mta-591.us.mimecast.lan>
@ 2024-05-27 9:15 ` Jakub Jelinek
0 siblings, 0 replies; 2+ messages in thread
From: Jakub Jelinek @ 2024-05-27 9:15 UTC (permalink / raw)
To: Richard Biener; +Cc: gcc-patches
On Mon, May 27, 2024 at 11:11:43AM +0200, Richard Biener wrote:
> 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.
LGTM, thanks.
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-05-27 9:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-27 9:11 [PATCH] tree-optimization/115232 - demangle failure during -Waccess Richard Biener
[not found] <64354.124052705114500359@us-mta-591.us.mimecast.lan>
2024-05-27 9:15 ` Jakub Jelinek
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).