www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20728] New: There is third way to create immutable data


          Issue ID: 20728
           Summary: There is third way to create immutable data
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dlang.org
          Assignee: nobody puremagic.com
          Reporter: porton narod.ru

https://dlang.org/spec/const3.html says that there are two ways of "Creating
immutable data".

I disagree, there is also the third way:

auto int x = 1;
void f(ref immutable int r) { }

This is neither literal nor cast to immutable data. It is the third way.

See also https://forum.dlang.org/post/lgkgcpxeyfrmuqlmigge forum.dlang.org as a
hint about the issue whether it actually creates immutable data.

Apr 10 2020