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

--- Comment #9 from Raffaello Bertini <raffaellobertini at gmail dot com> ---
More than to fix something,
it was a suggestion to evolve or add a warning to tell the user that those kind
of statements are basically like not written at all, ignored as the final
result.

so more than a fix, a small improvements on the compiler.

for e.g. doing the same operation with clang (default installation from Fedora
40):


clang test.c
=================================================================================
test.c:15:1: warning: 'const' qualifier on function type 'MyFunc' (aka 'void
(void)') has unspecified behavior
   15 | const MyFunc my_func;
      | ^~~~~
test.c:17:1: warning: 'const' qualifier on function type 'MyFunc' (aka 'void
(void)') has unspecified behavior
   17 | const MyFunc* g_f = my_func;
      | ^~~~~
2 warnings generated.


=================================================================================

clang -Wall -Werror test.c
================================================================================
test.c:15:1: error: 'const' qualifier on function type 'MyFunc' (aka 'void
(void)') has unspecified behavior [-Werror]
   15 | const MyFunc my_func;
      | ^~~~~
test.c:17:1: error: 'const' qualifier on function type 'MyFunc' (aka 'void
(void)') has unspecified behavior [-Werror]
   17 | const MyFunc* g_f = my_func;
      | ^~~~~
test.c:21:9: error: variable 'i' set but not used
[-Werror,-Wunused-but-set-variable]
   21 |     int i = 0;
      |         ^
3 errors generated.


================================================================================

Reply via email to