https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116767
--- Comment #4 from Martin Uecker <muecker at gwdg dot de> --- You are right about both. It gets miscompiled also with side effects and if you are remove the forward declaration, you get: <source>:10:21: warning: initialization makes '__attribute__((const))' qualified function pointer from unqualified [-Wdiscarded-qualifiers] 10 | const MyFunc* g_f = my_func;