public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/50593] New: improve __attribute__((format(printf)))
@ 2011-10-02 21:58 b.r.longbons at gmail dot com
  2011-10-03  8:54 ` [Bug c++/50593] " jakub at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: b.r.longbons at gmail dot com @ 2011-10-02 21:58 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-11-08 21:56 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-02 21:58 [Bug c++/50593] New: improve __attribute__((format(printf))) b.r.longbons at gmail dot com
2011-10-03  8:54 ` [Bug c++/50593] " jakub at gcc dot gnu.org
2011-10-04 10:31 ` paolo.carlini at oracle dot com
2011-10-15 20:56 ` paolo.carlini at oracle dot com
2011-10-15 20:59 ` paolo.carlini at oracle dot com
2011-10-15 21:17 ` [Bug c++/50593] [C++0x] " jason at gcc dot gnu.org
2011-10-15 21:57 ` paolo.carlini at oracle dot com
2011-11-08 21:59 ` david at rgmadvisors 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).