This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/81518] New: missing warning on a violation of attribute const requirements
- From: "msebor at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 22 Jul 2017 18:28:27 +0000
- Subject: [Bug c/81518] New: missing warning on a violation of attribute const requirements
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81518
Bug ID: 81518
Summary: missing warning on a violation of attribute const
requirements
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
The description of the const attribute in the GCC manual contains this note:
Note that a function that has pointer arguments and examines the data
pointed to must not be declared const. Likewise, a function that calls a
non-const function usually must not be const. It does not make sense for a
const function to return void.
Despite the note GCC doesn't issue a warning for function declarations that
violate these requirements. To help avoid user mistakes it would be helpful to
add such a warning.
$ cat a.c && gcc -O2 -S -Wall -Wextra -Wpedantic a.c
void f (void*) __attribute__ ((const));
$