https://gcc.gnu.org/g:0367efb112795290831bbc3eff181707fdfcc52c
commit r16-5691-g0367efb112795290831bbc3eff181707fdfcc52c Author: Jakub Jelinek <[email protected]> Date: Fri Nov 28 10:59:35 2025 +0100 c++: Remove PMF special cases from cxx_get_alias_set [PR119969] The use of 0 alias set for PMF * types seems to break modref for some reason, but because PMFs are canonicalized, there should be no reason to special case the alias set of PMF or PMF * anymore. 2025-11-27 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. Diff: --- gcc/cp/cp-objcp-common.cc | 6 ----- gcc/testsuite/g++.dg/torture/pr119969.C | 46 +++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/gcc/cp/cp-objcp-common.cc b/gcc/cp/cp-objcp-common.cc index c7e88cb7bfea..859c7d69746d 100644 --- a/gcc/cp/cp-objcp-common.cc +++ b/gcc/cp/cp-objcp-common.cc @@ -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); } diff --git a/gcc/testsuite/g++.dg/torture/pr119969.C b/gcc/testsuite/g++.dg/torture/pr119969.C new file mode 100644 index 000000000000..25a4053c3f87 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr119969.C @@ -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; +}
