Bug 1276 – static assert message displayed with escaped characters
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2007-06-18T11:11:00Z
Last change time
2014-02-16T15:25:42Z
Keywords
diagnostic
Assigned to
bugzilla
Creator
smjg
Comments
Comment #0 by smjg — 2007-06-18T11:11:52Z
If I try to make a static assert message span multiple lines, it doesn't work. This is because it tries to display it as a string in code, and in the process turns certain characters into their escape sequences.
----------
static assert (false,
"An error message
\tthat spans multiple lines, and also contains such characters as a tab,
\\ and \".");
----------
static_assert_linebreaks.d(1): static assert "An error message\x0a\x09that spans multiple lines, and also contains such characters as a tab,\x0a\\' and \"."
----------
Since the purpose of this is to display a message while running the compiler, it should just display the string, rather than a code representation of it. That is, the compiler output should look something like this:
static_assert_linebreaks.d(1): static assert is false: An error message
that spans multiple lines, and also contains such characters as a tab,
\ and ".
Comment #1 by davidl — 2007-06-19T06:15:06Z
Oh, u need to define valid escape sequence usable in that static assert specifically
consider:
static assert(false, "%s");
what supposed to be happen? surely not segfault or arbitrary strings.
so only \ leading ones need to be taken care of specially. while this complicates the compiler. I doubt if walter would love to implement it
in the near future :)
Comment #2 by smjg — 2007-06-19T06:31:26Z
There is no escape sequence in the string "%s". There are just two characters - '%' and 's'.
Comment #3 by onlystupidspamhere — 2007-06-26T14:29:55Z