https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83117
--- Comment #7 from rguenther at suse dot de <rguenther at suse dot de> --- On November 26, 2017 8:07:10 AM GMT+01:00, "jakub at gcc dot gnu.org" <gcc-bugzi...@gcc.gnu.org> wrote: >https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83117 > >--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> --- >The warning is nothing new, GCC has been warning for that for years. >What my >patch did is just better optimization, so the compiler can see the UB. > >Try: >extern long do_test_aligned (); > >static long (*const do_test_v1) (long a, ...) = (void *) >do_test_aligned; > >extern void check_results (long); > >int test (long a) >{ > long ret; > > ret = do_test_v1 (a); > ret += (long (*) (long a, ...)) do_test_aligned; > check_results (ret); >} > >We've warned about the latter, but not the former, since we weren't >able to >fold a const var to its initializer. > >So, either the tests shouldn't use const on these, something like: >- out << "static __attribute__ ((ms_abi)) long (*const >do_test_" >+ out << "static __attribute__ ((ms_abi)) long (*do_test_" >or they should use const volatile, or -w, or should use proper >prototypes. > >Daniel needs to decide what to do, it isn't obviously clear what the >intent is. The intent of the test was probably to force an indirect call.