Rationale for -Wignored-qualifiers

Joel Sherrill joel@rtems.org
Fri Oct 17 14:45:53 GMT 2025


Hi

I have been trying to eliminate all warnings at -Wextra for RTEMS before we
make our next major release. There were a handful of cases where
-Wignored-qualifiers. I understand it is meaningless to have qualifiers on
scalar return values, but I was hoping someone here might have more to add
for rationale than "has no effect".

Is there any coding standard (MISRA, JPL, etc.) where this is explicitly
forbidden? Or mentioned?

-Wignored-qualifiers (C and C++ only)
Warn if the return type of a function has a type qualifier such as const.
For ISO C such a type qualifier has no effect, since the value returned by
a function is not an lvalue. For C++, the warning is only emitted for
scalar types or void. ISO C prohibits qualified void return types on
function definitions, so such return types always receive a warning even
without this option.

I have attached a simple C function which generates the warning if that
helps anyone.

Thanks.

--Joel Sherrill
RTEMS
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ignored-qualifier.c
Type: application/octet-stream
Size: 106 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20251017/1259e92e/attachment.obj>


More information about the Gcc mailing list