www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22782] New: [dip1000] string escaped by throwing constructor

https://issues.dlang.org/show_bug.cgi?id=22782

          Issue ID: 22782
           Summary: [dip1000] string escaped by throwing constructor
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: Ajieskola gmail.com

------
struct DontDoThis
{ immutable char[12] content;
   safe this(char ch)
  { content[] = ch;
    throw new Exception(content[]);
  }
}

void main()  safe
{ import std.stdio;
  DontDoThis('a');
}
------

Prints a garbage error message. Compiled with -preview=dip1000, using latest
master.

--
Feb 16 2022