[Bug c/66425] (void) cast doesn't suppress __attribute__((warn_unused_result))
fw at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Jul 17 14:00:10 GMT 2024
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425
--- Comment #74 from Florian Weimer <fw at gcc dot gnu.org> ---
(In reply to Zdenek Sojka from comment #73)
> See MISRA C:2012 Rule 17.7:
> "... If the return value of a function is intended not to be used
> explicitly, it should be cast to the void type. ..."
>
> It would be helpful if gcc could be used to write MISRA-compliant code, or
> at least if it wouldn't generate compilation warnings when the programmer is
> targeting MISRA-compliancy.
Doesn't this (interpretation of MISRA) mean that compliant code cannot use
__attribute__((warn_unused_result))? That doesn't require any GCC changes.
More information about the Gcc-bugs
mailing list