[Issue 21807] New: Non-immutable data can be converted to immutable using function call in ctor

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Apr 7 01:22:10 UTC 2021


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

          Issue ID: 21807
           Summary: Non-immutable data can be converted to immutable using
                    function call in ctor
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: critical
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: temtaime at gmail.com

class Foo
{
        this()
        {
                // char[12] pp; str = pp; // error 
                str = bb(); // no error ???
        }

        string str;
}

char[12] bb()
{
        char[12] res;
        return res;
}

Also why it doesn't produce 
Error: escaping reference to stack allocated value returned by bb()

???

--


More information about the Digitalmars-d-bugs mailing list