www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18100] New: crt_constructor not allow to init immutable

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

          Issue ID: 18100
           Summary: crt_constructor  not allow to init immutable
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: blocker
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: changlon gmail.com

=========== code ============
static immutable int my_i ;
int test(){
        return 3;
}

shared static this(){
        my_i = test();  // work 
}
pragma(crt_constructor) extern(C) void init1(){
        my_i = test(); //   Error: cannot modify immutable expression my_i
}
==========================

--
Dec 17 2017