www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18003] New: assert performs implicit conversion of mutable


          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 puremagic.com
          Reporter: hsteoh quickfur.ath.cx

void f() {
        char[6] err = "Argh!";
        assert(0, err[0 .. $]);
void main() {

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

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)[].

Nov 21 2017