From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1847 invoked by alias); 30 Sep 2011 07:47:12 -0000 Received: (qmail 1835 invoked by uid 22791); 30 Sep 2011 07:47:10 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 30 Sep 2011 07:46:56 +0000 From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/38980] [4.4/4.5/4.6/4.7 Regression] missing -Wformat warning on const char format string Date: Fri, 30 Sep 2011 08:31:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.4.7 X-Bugzilla-Changed-Fields: Status Last reconfirmed CC Target Milestone Summary Ever Confirmed Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-09/txt/msg02354.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38980 Jakub Jelinek 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 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.