www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19092] New: __delete doesn't work with immutable


          Issue ID: 19092
           Summary: __delete doesn't work with immutable
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: blocker
          Priority: P1
         Component: druntime
          Assignee: nobody puremagic.com
          Reporter: radu.racariu gmail.com

The following program
void main()
    import core.memory : __delete;

    immutable(int)[] x;

Fails to compile
/dlang/dmd/linux/bin64/../../src/druntime/import/core/memory.d(1022): Error:
function core.memory.GC.free(void* p) is not callable using argument types
cannot pass argument cast(immutable(int)*)x of type immutable(int)* to
parameter void* p
onlineapp.d(7): Error: template instance
`core.memory.__delete!(immutable(int)[])` error instantiating

If `__delete` is suppose to be an alternative to `delete` then it has to
support all use cases.

As this compiles (with the deprecation warning)
void main()
    immutable(int)[] x;

    delete x;

Jul 18 2018