digitalmars.D - Make string literals immutable in Windows
- Andrew Pennebaker (6/6) Nov 29 2018 I was surprised to read from the FreeBSD documentation that D
- Adam D. Ruppe (5/7) Nov 29 2018 I don't think that is true anymore, but even if it is, you would
- bauss (8/14) Nov 30 2018 They're not writable in the sense you think so it doesn't really
- Jacob Carlborg (7/14) Dec 01 2018 I know in the D1 days when a string literal was of the type "char[]".
- John Colvin (4/10) Dec 01 2018 Please provide an example of valid D program that does this.
I was surprised to read from the FreeBSD documentation that D string literals are actually writeable in Windows: https://dlang.org/dmd-freebsd.html Can we fix that? I think C literals were already immutable, though I'm not sure about the particulars of the Visual Studio C/C++ semantics.
Nov 29 2018
On Thursday, 29 November 2018 at 23:56:27 UTC, Andrew Pennebaker wrote:I was surprised to read from the FreeBSD documentation that D string literals are actually writeable in Windows:I don't think that is true anymore, but even if it is, you would have to cast away the language-level immutable to get to it, so it is undefined behavior anyway.
Nov 29 2018
On Thursday, 29 November 2018 at 23:56:27 UTC, Andrew Pennebaker wrote:I was surprised to read from the FreeBSD documentation that D string literals are actually writeable in Windows: https://dlang.org/dmd-freebsd.html Can we fix that? I think C literals were already immutable, though I'm not sure about the particulars of the Visual Studio C/C++ semantics.They're not writable in the sense you think so it doesn't really matter. Strings are still constructed as immutable(char)[] on Windows. It's the same across all platforms. I guess the difference is that you can cast immutable away and that's UB and thus it doesn't really matter.
Nov 30 2018
On 2018-11-30 10:24, bauss wrote:They're not writable in the sense you think so it doesn't really matter. Strings are still constructed as immutable(char)[] on Windows. It's the same across all platforms. I guess the difference is that you can cast immutable away and that's UB and thus it doesn't really matter.I know in the D1 days when a string literal was of the type "char[]". Then string literals were placed in a read only section in the binary on Posix, trying to modify a string literal caused a segfault (or similar). On Windows it worked fine to modify a string literal. -- /Jacob Carlborg
Dec 01 2018
On Thursday, 29 November 2018 at 23:56:27 UTC, Andrew Pennebaker wrote:I was surprised to read from the FreeBSD documentation that D string literals are actually writeable in Windows: https://dlang.org/dmd-freebsd.html Can we fix that? I think C literals were already immutable, though I'm not sure about the particulars of the Visual Studio C/C++ semantics.Please provide an example of valid D program that does this. Seriously though, it would be a nice thing to have.
Dec 01 2018