On 11/28/25 2:51 PM, Jakub Jelinek wrote:
On Thu, Nov 27, 2025 at 11:18:52AM +0530, Jason Merrill wrote:
I wouldn't expect that to be an issue, the POINTER_TYPE to METHOD_TYPE.is
immediately wrapped in the PMF RECORD_TYPE.
The comment suggests that the problem is that METHOD_TYPE isn't
canonicalized properly, but build_method_type_directly sure seems to work to
do that, so perhaps the comment is obsolete and we can just return -1?
That comment goes back to r81764 (6de9cd9a886ea695aa892c3c7c07818a7b7e9e6f),
the tree-ssa merge.
Seems removing all the PMF special cases works just fine during
bootstrap/regtest, so here is an updated patch.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
OK.
2025-11-28 Jakub Jelinek <[email protected]>
PR c++/119969
* cp-objcp-common.cc (cxx_get_alias_set): Remove special cases
for TYPE_PTRMEMFUNC_P and INDIRECT_TYPE_P for TYPE_PTRMEMFUNC_P.
* g++.dg/torture/pr119969.C: New test.
--- gcc/cp/cp-objcp-common.cc.jj 2025-11-26 22:07:16.253007984 +0100
+++ gcc/cp/cp-objcp-common.cc 2025-11-27 19:08:27.951136838 +0100
@@ -180,12 +180,6 @@ cxx_get_alias_set (tree t)
complete type. */
return get_alias_set (TYPE_CONTEXT (t));
- /* Punt on PMFs until we canonicalize functions properly. */
- if (TYPE_PTRMEMFUNC_P (t)
- || (INDIRECT_TYPE_P (t)
- && TYPE_PTRMEMFUNC_P (TREE_TYPE (t))))
- return 0;
-
return c_common_get_alias_set (t);
}
--- gcc/testsuite/g++.dg/torture/pr119969.C.jj 2025-11-25 12:38:20.120143562 +0100
+++ gcc/testsuite/g++.dg/torture/pr119969.C 2025-11-25 12:38:42.407758775
+0100
@@ -0,0 +1,46 @@
+// PR c++/119969
+// { dg-do run }
+
+struct S {};
+using PMF = void (S::*)();
+using Block = PMF[16];
+using BlockPtr = Block*;
+
+struct IteratorImp {
+ Block** d_blockPtr_p;
+ PMF* d_value_p;
+
+ void operator++();
+ PMF& operator*() const { return *d_value_p; }
+};
+
+void IteratorImp::operator++() {
+ int offset = 1 + (d_value_p - **d_blockPtr_p);
+ d_blockPtr_p += offset / 16;
+ d_value_p = **d_blockPtr_p + (offset % 16);
+}
+
+struct iterator {
+ IteratorImp d_imp;
+};
+
+struct D {
+ Block* d_blockPtrs[1];
+ Block d_block;
+ PMF* d_start_p;
+};
+
+D mX;
+
+void privateInit(int numElements) {
+ mX.d_blockPtrs[0] = &mX.d_block;
+ mX.d_start_p = mX.d_block + (numElements + 7);
+}
+
+int main() {
+ privateInit(0);
+ iterator cbgn = {{mX.d_blockPtrs, mX.d_block + 7}};
+ auto clast = cbgn;
+ ++clast.d_imp;
+ if (&*cbgn.d_imp == &*clast.d_imp) return 1;
+}
Jakub