Why use a DFA instead of DIP1000?
kdevel
kdevel at vogtner.de
Sat Sep 13 13:06:06 UTC 2025
On Saturday, 13 September 2025 at 11:08:29 UTC, IchorDev wrote:
> [...]
>> What about "release" mode? And what about that code:
>>
>> ```d
>> void main ()
>> {
>> assert (0);
>>
>> string s = "x";
>> s [0] = 'y';
>> }
>> ```
>
> The program has entered an invalid state and the behaviour of
> the continuing execution of the program is undefined.
Please note that the program is not run but just compiled.
> [...]
>> Is "Error: cannot modify `immutable` expression `s[0]`" a
>> false positive, too?
>
> It's not a 'false positive' because it's not related to
> DIP1000's stack escape rules at all.
I thought that the intent of the original code
```d
int* ptr;
void func(bool b, scope int* p) @safe {
assert(!b);
if (b) {
ptr = p; // Error: scope variable `p` assigned to global
variable `ptr`
}
}
```
was to show that there is some code-block
```d
ptr = p; // Error: scope variable `p` assigned to global
variable `ptr`
```
which is never executed regardless of the value of `b`.
More information about the Digitalmars-d
mailing list