This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/83559] New: -Wsuggest-attribute=const conflicts with -Wattributes warning about const attribute on function returning void
- From: "egallager at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 22 Dec 2017 16:29:35 +0000
- Subject: [Bug c/83559] New: -Wsuggest-attribute=const conflicts with -Wattributes warning about const attribute on function returning void
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83559
Bug ID: 83559
Summary: -Wsuggest-attribute=const conflicts with -Wattributes
warning about const attribute on function returning
void
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: egallager at gcc dot gnu.org
CC: msebor at gcc dot gnu.org
Target Milestone: ---
Created attachment 42955
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42955&action=edit
testcase
Say I have this source and compile it:
$ cat suggest_attribute_const.c
struct frame_info;
void
show_stack_frame(struct frame_info *fi)
{
(void)fi;
return;
}
void __attribute__((const))
show_stack_frame_2(struct frame_info *fi)
{
(void)fi;
return;
}
$ /usr/local/bin/gcc -c -Wattributes -Wsuggest-attribute=const -O2
suggest_attribute_const.c
suggest_attribute_const.c:12:1: warning: 'const' attribute on function
returning 'void' [-Wattributes]
{
^
suggest_attribute_const.c: In function 'show_stack_frame':
suggest_attribute_const.c:4:1: warning: function might be candidate for
attribute 'const' [-Wsuggest-attribute=const]
show_stack_frame(struct frame_info *fi)
^~~~~~~~~~~~~~~~
$
The 2 functions are basically the same, except the 2nd one has attribute const
added to silence the warning from the first one. Except that now provokes a new
warning from -Wattributes, which, to silence, requires removing the attribute,
which brings the original -Wsuggest-attribute=const back. This conflict between
warnings should be resolved.