[Bug target/126628] dllimport-ed PMF has invalid address in initializer_list
tim at klingt dot org via Gcc-bugs <[email protected]> Tue, 04 Aug 2026 04:46:47 +0000
| Newsgroups | gmane.comp.gcc.bugs |
|---|---|
| Message-ID | <[email protected]/bugzilla/> |
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D126628
--- Comment #2 from tim blechmann <tim at klingt dot org> ---
> There was a change in GCC 15 to make initializer_list array constant (read
> only). This sounds like the wrong section is being used for constant arra=
ys
> of (dll_import) function pointers in general.=20=20
>=20
>=20
> Does it happen if you simple things like:
> typedef void (*fp)(void);
> const fp array[] =3D {func1, func2, func3};
>=20
> [[gnu::noipa]]
> const fp *g()
> {
> return array;
> }
>=20
> And then use g() ?
this also seems to give wrong addresses:
```
const PMF array[] =3D {&Foo::methodA, &Foo::methodB, &Foo::methodC};
[[gnu::noipa]]
const PMF *g()
{
return array;
}
```
while this gives the correct ones:
```
const PMF array[] =3D {&Foo::methodA, &Foo::methodB, &Foo::methodC};
[[gnu::noipa]]
const PMF *g()
{
static PMF array[3];
array[0] =3D &Foo::methodA;
array[1] =3D &Foo::methodB;
array[2] =3D &Foo::methodC;
return array;
}
```=