Segfault when writing to module-scope dynamic array
Adam D. Ruppe
destructionator at gmail.com
Mon Nov 18 13:28:26 UTC 2019
On Monday, 18 November 2019 at 13:22:20 UTC, rombankzero wrote:
> Yeah, that appears to be what's happening. For the record, I
> tried it on both Linux and Windows, and only got a segfault on
> Linux.
Yeah, that's consistent with other strings too. (The D type
system calls both immutable, but the OS is looser on Windows. at
least 32 bit.)
> Are there cases where this behavior is useful?
Yeah, it is cool for sentinel objects and default settings.
Usually best when coupled with immutable to prevent more
confusion but mutable versions sometimes make sense too.
But it is rare and if you aren't specifically looking for it
knowing the details, it isn't right. And since the syntax looks
so normal it trips up a LOT of people.
I think the compiler should probably start to error on it, and if
you know what you're doing, maybe mark it special somehow. idk.
More information about the Digitalmars-d-learn
mailing list