[Issue 18003] New: assert performs implicit conversion of mutable local static char array to string
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Nov 21 19:29:00 UTC 2017
https://issues.dlang.org/show_bug.cgi?id=18003
Issue ID: 18003
Summary: assert performs implicit conversion of mutable local
static char array to string
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: hsteoh at quickfur.ath.cx
Code:
------
void f() {
char[6] err = "Argh!";
assert(0, err[0 .. $]);
}
void main() {
f();
}
------
In the assert output, the message is garbled because it's a slice of the local
variable `err`, which has gone out of scope by the time the error message is
displayed.
Expected behaviour: assert() should not allow mutable char[] as second
argument, or the compiler should not allow implicit conversion of a mutable
char[] slice to immutable(char)[].
--
More information about the Digitalmars-d-bugs
mailing list