[Bug c++/38980] [4.4/4.5/4.6/4.7 Regression] missing -Wformat warning on const char format string
jakub at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Sep 30 08:31:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38980
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2011-09-30
CC| |jason at gcc dot gnu.org,
| |jsm28 at gcc dot gnu.org
Target Milestone|--- |4.4.7
Summary|missing -Wformat warning on |[4.4/4.5/4.6/4.7
|const char format string |Regression] missing
| |-Wformat warning on const
| |char format string
Ever Confirmed|0 |1
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-09-30 07:46:22 UTC ---
I think this has been caused by
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21089#c25
The c-format* stuff uses decl_constant_value, for C it will for
const array variable with STRING_CST DECL_INITIAL return the DECL_INITIAL, but
in C++ I think since the above commit it will not:
105256 mmitchel /* Do not return an aggregate constant (of
which
105256 mmitchel string literals are a special case), as we
do not
106533 kazu want to make inadvertent copies of such
entities,
105256 mmitchel and we must be sure that their addresses
are the
105256 mmitchel same everywhere. */
105256 mmitchel || TREE_CODE (init) == CONSTRUCTOR
105256 mmitchel || TREE_CODE (init) == STRING_CST)))
So, either we need a different function or an argument to decl_constant_value
to force returning STRING_CST in that case, because in c-format case making
inadvertent copies of such entities isn't a problem, c-format only wants to
check that literal.
More information about the Gcc-bugs
mailing list