array literals and the read only segment

Shachar Shemesh via Digitalmars-d digitalmars-d at puremagic.com
Sun Dec 11 04:48:17 PST 2016


Hello everyone,

Please consider the following snippet:
immutable ubyte[] array1 = [ 1, 2, 3, 4 ];
immutable ubyte[] array2 = cast(immutable ubyte[]) x"01 02 03 04";

Examining the resulting code, it is obvious that the literals 
initializing array2 are stored in the read only segment (.rodata), as 
they should be. It is equally obvious that array1 is stored in the data 
segment.

This is bad for a variety of reasons.

Is this a know issue?

Shachar


More information about the Digitalmars-d mailing list