Hi,
this issue, reported by Dave (and Jon), is about the error message
printed for a static_assert like:
static_assert('X' != '\130', "'X' has the wrong value");
where, due to the use of %E, we go through pp_c_string_literal and thus
pp_c_char, and we escape the single quotes around X. Dave also
recommends not using *any* quotes around the string.
Thus, just using %s on the TREE_STRING_POINTER seems a straightforward
fix to me (but in fact %qs also passes the testsuite).
Tested x86_64-linux.
Thanks,
Paolo.
//////////////////////
/cp
2011-12-31 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/51397
* semantics.c (finish_static_assert): Use %s instead of %E for
the error message.
/testsuite
2011-12-31 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/51397
* g++.dg/cpp0x/static_assert6.C: New.
Index: testsuite/g++.dg/cpp0x/static_assert6.C
===================================================================
--- testsuite/g++.dg/cpp0x/static_assert6.C (revision 0)
+++ testsuite/g++.dg/cpp0x/static_assert6.C (revision 0)
@@ -0,0 +1,4 @@
+// PR c++/51397
+// { dg-options "-std=c++0x" }
+
+static_assert('X' != '\130', "'X' has the wrong value"); // { dg-error "'X'
has the wrong value" }
Index: cp/semantics.c
===================================================================
--- cp/semantics.c (revision 182754)
+++ cp/semantics.c (working copy)
@@ -5127,7 +5127,7 @@ finish_static_assert (tree condition, tree message
if (TREE_CODE (condition) == INTEGER_CST
&& integer_zerop (condition))
/* Report the error. */
- error ("static assertion failed: %E", message);
+ error ("static assertion failed: %s", TREE_STRING_POINTER (message));
else if (condition && condition != error_mark_node)
{
error ("non-constant condition for static assertion");