https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126628

--- 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 arrays
> of (dll_import) function pointers in general.  
> 
> 
> Does it happen if you simple things like:
> typedef void (*fp)(void);
> const fp array[] = {func1, func2, func3};
> 
> [[gnu::noipa]]
> const fp *g()
> {
>   return array;
> }
> 
> And then use g() ?

this also seems to give wrong addresses:
```
const PMF array[] = {&Foo::methodA, &Foo::methodB, &Foo::methodC};

[[gnu::noipa]]
const PMF *g()
{
    return array;
}
```

while this gives the correct ones:
```

const PMF array[] = {&Foo::methodA, &Foo::methodB, &Foo::methodC};

[[gnu::noipa]]
const PMF *g()
{
    static PMF array[3];
    array[0] = &Foo::methodA;
    array[1] = &Foo::methodB;
    array[2] = &Foo::methodC;

    return array;
}
```

Reply via email to