public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/55830] New: inline and __attribute__((always_inline)) treated differently for unused-function warning
@ 2012-12-30 21:39 brooks at gcc dot gnu.org
2012-12-30 21:42 ` [Bug c/55830] " pinskia at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: brooks at gcc dot gnu.org @ 2012-12-30 21:39 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55830
Bug #: 55830
Summary: inline and __attribute__((always_inline)) treated
differently for unused-function warning
Classification: Unclassified
Product: gcc
Version: 4.7.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: brooks@gcc.gnu.org
Consider the case of a header file containing definitions of static inline
functions, included in a number of source files (which may not use all of the
defined functions), compiled with C99 and -Wall -Wextra.
If the functions are defined as "static inline", GCC will mask the "unused
function" warning.
However, if the functions are defined as "static
__attribute__((always_inline))", then GCC will omit "unused function" warnings
whenever one of them is not used in a given source file.
This really should be consistent, and it would be ideal to maintain the
no-warning behavior and have that apply to both cases.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/55830] inline and __attribute__((always_inline)) treated differently for unused-function warning
2012-12-30 21:39 [Bug c/55830] New: inline and __attribute__((always_inline)) treated differently for unused-function warning brooks at gcc dot gnu.org
@ 2012-12-30 21:42 ` pinskia at gcc dot gnu.org
2012-12-30 21:46 ` brooks at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-12-30 21:42 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55830
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-12-30 21:42:28 UTC ---
IIRC always_inline really needs inline also.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/55830] inline and __attribute__((always_inline)) treated differently for unused-function warning
2012-12-30 21:39 [Bug c/55830] New: inline and __attribute__((always_inline)) treated differently for unused-function warning brooks at gcc dot gnu.org
2012-12-30 21:42 ` [Bug c/55830] " pinskia at gcc dot gnu.org
@ 2012-12-30 21:46 ` brooks at gcc dot gnu.org
2012-12-30 21:50 ` brooks at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: brooks at gcc dot gnu.org @ 2012-12-30 21:46 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55830
--- Comment #2 from Brooks Moses <brooks at gcc dot gnu.org> 2012-12-30 21:46:02 UTC ---
Created attachment 29064
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29064
Minimal test case
The attached test case illustrates the problem. When compiled with -Wall
-Wextra -Werror, it reports:
bug55830.c:6:44: warning: 'bar' defined but not used
However, it does not report a similar warning for 'foo'.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/55830] inline and __attribute__((always_inline)) treated differently for unused-function warning
2012-12-30 21:39 [Bug c/55830] New: inline and __attribute__((always_inline)) treated differently for unused-function warning brooks at gcc dot gnu.org
2012-12-30 21:42 ` [Bug c/55830] " pinskia at gcc dot gnu.org
2012-12-30 21:46 ` brooks at gcc dot gnu.org
@ 2012-12-30 21:50 ` brooks at gcc dot gnu.org
2012-12-30 22:12 ` schwab@linux-m68k.org
2013-02-28 18:19 ` colanderman at gmail dot com
4 siblings, 0 replies; 6+ messages in thread
From: brooks at gcc dot gnu.org @ 2012-12-30 21:50 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55830
--- Comment #3 from Brooks Moses <brooks at gcc dot gnu.org> 2012-12-30 21:50:08 UTC ---
Andrew: Oh, interesting. So perhaps this is really a failure to warn (or
error?) for a case where "__attribute__((always_inline))" isn't used with
"inline", and a case of missing documentation on the always_inline attribute?
FWIW, the additional "inline" certainly doesn't seem to be needed in practice
for GCC to inline the code.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/55830] inline and __attribute__((always_inline)) treated differently for unused-function warning
2012-12-30 21:39 [Bug c/55830] New: inline and __attribute__((always_inline)) treated differently for unused-function warning brooks at gcc dot gnu.org
` (2 preceding siblings ...)
2012-12-30 21:50 ` brooks at gcc dot gnu.org
@ 2012-12-30 22:12 ` schwab@linux-m68k.org
2013-02-28 18:19 ` colanderman at gmail dot com
4 siblings, 0 replies; 6+ messages in thread
From: schwab@linux-m68k.org @ 2012-12-30 22:12 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55830
--- Comment #4 from Andreas Schwab <schwab@linux-m68k.org> 2012-12-30 22:12:28 UTC ---
static alone already makes a function eligible for inlining.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/55830] inline and __attribute__((always_inline)) treated differently for unused-function warning
2012-12-30 21:39 [Bug c/55830] New: inline and __attribute__((always_inline)) treated differently for unused-function warning brooks at gcc dot gnu.org
` (3 preceding siblings ...)
2012-12-30 22:12 ` schwab@linux-m68k.org
@ 2013-02-28 18:19 ` colanderman at gmail dot com
4 siblings, 0 replies; 6+ messages in thread
From: colanderman at gmail dot com @ 2013-02-28 18:19 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55830
Chris King <colanderman at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |colanderman at gmail dot
| |com
--- Comment #5 from Chris King <colanderman at gmail dot com> 2013-02-28 18:18:37 UTC ---
This is good. I like that I can specify __attribute__ ((always_inline)) on
local static functions and still be warned if they are unused. IMHO the real
bug is that such usage triggers a "warning: always_inline function might not be
inlinable".
If this bug and/or the above warning behavior is valid, then what's the
"correct" way to say "I want my local static function to be always inlined, but
don't hide warnings if it's unused"?
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-02-28 18:19 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-30 21:39 [Bug c/55830] New: inline and __attribute__((always_inline)) treated differently for unused-function warning brooks at gcc dot gnu.org
2012-12-30 21:42 ` [Bug c/55830] " pinskia at gcc dot gnu.org
2012-12-30 21:46 ` brooks at gcc dot gnu.org
2012-12-30 21:50 ` brooks at gcc dot gnu.org
2012-12-30 22:12 ` schwab@linux-m68k.org
2013-02-28 18:19 ` colanderman at gmail dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).