[Bug c++/51397] New: static_assert message formatting

dave@boost-consulting.com gcc-bugzilla@gcc.gnu.org
Sat Dec 3 22:07:00 GMT 2011


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51397

             Bug #: 51397
           Summary: static_assert message formatting
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: dave@boost-consulting.com


I just noticed that GCC can be overly-helpful ;-) when formatting a
static assertion message:

    static_assert('X' != '\130',"'X' has the wrong value");

gives me

    error: static assertion failed: "\'X\' has the wrong value"

I suggest that GCC should drop the surrounding quotes and not try to
escape any characters in the message.  Otherwise, things like

    #define static_assert_(x) static_assert(x, #x)
    static_assert_('X' != '\130')

turn out quite badly.

The point of this facility is, after all, to help programmers report legible
errors!



More information about the Gcc-bugs mailing list