1276 – static assert message displayed with escaped characters

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 1276 - static assert message displayed with escaped characters
Summary: static assert message displayed with escaped characters
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 Windows
: P2 normal
Assignee: Walter Bright
URL:
Keywords: diagnostic
Depends on:
Blocks:
Reported: 2007年06月18日 11:11 UTC by Stewart Gordon
Modified: 2014年02月16日 15:25 UTC (History)
0 users

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Stewart Gordon 2007年06月18日 11:11:52 UTC
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 david 2007年06月19日 06:15:06 UTC
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 Stewart Gordon 2007年06月19日 06:31:26 UTC
There is no escape sequence in the string "%s". There are just two characters - '%' and 's'.
Comment 3 Jari-Matti Mäkelä 2007年06月26日 14:29:55 UTC
Fixed in 1.017.


AltStyle によって変換されたページ (->オリジナル) /