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.
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;
--- /dev/null
+// { 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>();
+}