From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3348 invoked by alias); 2 Oct 2011 21:58:02 -0000 Received: (qmail 3340 invoked by uid 22791); 2 Oct 2011 21:58:01 -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; Sun, 02 Oct 2011 21:57:46 +0000 From: "b.r.longbons at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/50593] New: improve __attribute__((format(printf))) Date: Sun, 02 Oct 2011 21:58:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: b.r.longbons at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: 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-10/txt/msg00070.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50593 Bug #: 50593 Summary: improve __attribute__((format(printf))) Classification: Unclassified Product: gcc Version: 4.6.1 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: b.r.longbons@gmail.com Created attachment 25398 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25398 8 tests There are a number of cases where the compiler should be able to use a constant string to check the arguments of a printf-like function. Expected Result: GCC always warns about format argument errors, when it can. Actual Result: GCC only warns in a couple of cases. In particular, note: * const char[] works in C but not C++. * Directly using the result of a constexpr function doesn't work, but assigning it to a variable does. (This is fortunate, because it allowed me to write the most awesome code ever, a safe wrapper that allows passing e.g. a std::string to printf!) Versions tested: All tests: 4.6.1 (gentoo), r179098 from branch 4.6, and trunk sometime near that. Tests 1,2,6,7,8 (without constexpr): 4.5.3, 4.4.6, 4.3.6 (gentoo) Tests 1,2 (C++98): 4.2.4 (gentoo) Tests 1,2 in C: all mentioned versions.