https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120010
Bug ID: 120010
Summary: __attribute__((unused)) does not work for function
arguments
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: hpa at zytor dot com
Target Milestone: ---
Created attachment 61242
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=61242&action=edit
Test case
__attribute__((unused)) on a type is there to mark that "a variable of that
type are meant to appear possibly unused."
However, it does not work as advertised if that type is used as a function
argument, which is one way that a variable can be created.
This can be a result of different code configuration, for example.
Attached test case when compiled with gcc 15.0.1 20250329 (Fedora 42):
gcc -O2 -Wall -Wextra -c unused.c
unused.c: In function ‘unused’:
unused.c:3:28: warning: unused parameter ‘b’ [-Wunused-parameter]
3 | int unused(int a, unused_t b, int c)
| ~~~~~~~~~^
Note the warning for the argument b, but not the local variable d.