[llvm-bugs] [Bug 26225] New: static_assert does not respect new-lines

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jan 20 13:29:47 PST 2016


https://llvm.org/bugs/show_bug.cgi?id=26225

            Bug ID: 26225
           Summary: static_assert does not respect new-lines
           Product: new-bugs
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: metaprogrammingtheworld at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

This may or may not be considered a bug -- when a static_assert message
contains a '\n' character, the text "\n" is currently printed as opposed to an
actual new line. This is more unfortunate than it might seem because spacing
and new lines in static_assert messages can greatly improve the readability of
user-provided error messages.

Notably, GCC prints an actual new line when the new-line character is
encountered.

Example:

////////////////////
static_assert(false,
  "\n****************************************\n"
  "Error: The third macro argument that was "
  "provided to FOO is invalid (it was not parenthesized). Saw:\n"
  "std::array<int, 5>\n"
  "Did you mean:\n"
  "(std::array<int, 5>)"
  "\n****************************************\n");

int main() {}
////////////////////

In GCC, this nicely prints:

1 : error: static assertion failed:
****************************************
Error: The third macro argument that was provided to FOO is invalid (it was not
parenthesized). Saw:
std::array<int, 5>
Did you mean:
(std::array<int, 5>)
****************************************

While in Clang, this prints:

1 : error: static_assert failed
"\n****************************************\nError: The third macro argument
that was provided to FOO is invalid (it was not parenthesized).
Saw:\nstd::array<int, 5>\nDid you mean:\n(std::array<int,
5>)\n****************************************\n"

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160120/ed6d6dd6/attachment.html>


More information about the llvm-bugs mailing list