Re: How to force an array literal into a read-only data segment?

2019-09-12 Thread Max Samukha via Digitalmars-d-learn
On Thursday, 12 September 2019 at 08:54:09 UTC, a11e99z wrote: On Thursday, 12 September 2019 at 07:04:19 UTC, Max Samukha wrote: How to achieve the same for an array literal? The closest I could come: enum immutable(int[3]) _tmp = [1, 2, 3]; __gshared a = _tmp.ptr; Is it possible to force

Re: How to force an array literal into a read-only data segment?

2019-09-12 Thread a11e99z via Digitalmars-d-learn
On Thursday, 12 September 2019 at 07:04:19 UTC, Max Samukha wrote: How to achieve the same for an array literal? The closest I could come: enum immutable(int[3]) _tmp = [1, 2, 3]; __gshared a = _tmp.ptr; Is it possible to force the array into rodata?

How to force an array literal into a read-only data segment?

2019-09-12 Thread Max Samukha via Digitalmars-d-learn
test.d: __gshared t = "text".ptr; As expected, the "text" literal ends up in a read-only data segment, with a pointer to it stored in a writable data segment (_TMP0 pointing into .rodata.str1.1): .data segment _D4test1tPya: dd offset FLAT:_TMP0@64 db