diff options
author | Richard Biener <rguenther@suse.de> | 2024-05-27 09:13:11 +0200 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2024-05-27 11:24:04 +0200 |
commit | 311d7f5c17b8969c7ed8e4f23178d6ec4752e33f (patch) | |
tree | ae1c2ff3af194581d2e2a9943d12298cc30685ca /gcc | |
parent | 88c9b96b2800ddb7a499bd10abaa9441a471d5fe (diff) | |
download | gcc-311d7f5c17b8969c7ed8e4f23178d6ec4752e33f.zip gcc-311d7f5c17b8969c7ed8e4f23178d6ec4752e33f.tar.gz gcc-311d7f5c17b8969c7ed8e4f23178d6ec4752e33f.tar.bz2 |
tree-optimization/115232 - demangle failure during -Waccess
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.
PR tree-optimization/115232
* gimple-ssa-warn-access.cc (new_delete_mismatch_p): Handle
failure to demangle gracefully.
* g++.dg/pr115232.C: New testcase.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/gimple-ssa-warn-access.cc | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/pr115232.C | 25 |
2 files changed, 26 insertions, 1 deletions
diff --git a/gcc/gimple-ssa-warn-access.cc b/gcc/gimple-ssa-warn-access.cc index 0cd5b6d..61f9f0f 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 0000000..e1d96d8 --- /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>(); +} |