Non-techincal brain, is @safe by default good or not?

Mathias LANG geod24 at gmail.com
Thu May 28 12:36:58 UTC 2020


On Thursday, 28 May 2020 at 10:46:08 UTC, Andrei Alexandrescu 
wrote:
> On 5/28/20 6:28 AM, Mathias LANG wrote:
>> 
>> import std.algorithm.mutation;
>> struct S
>> {
>>      void opPostMove(const ref S old) @system nothrow pure
>>      {
>>          int* ptr = cast(int*)42;
>>          *ptr = 42;
>>      }
>>      int a;
>> }
>> void main () @safe nothrow
>> {
>>      S s1;
>>      s1.a = 41;
>>      S s2 = move(s1); // BOOM
>>      assert(s2.a == 42);
>> }
>> ```
>> 
>> This compiles and crash just fine.
>
> At least this is a legit bug report.

Well since you like it (filed as 
https://issues.dlang.org/show_bug.cgi?id=20869) I went ahead and 
did a quick search on trusted:
- https://issues.dlang.org/show_bug.cgi?id=20870
- https://issues.dlang.org/show_bug.cgi?id=20871
- https://issues.dlang.org/show_bug.cgi?id=20872
- https://issues.dlang.org/show_bug.cgi?id=20873

But as fun as it is to find those in Phobos, it's nothing in 
comparison of the language holes we still have. E.g. today Andrej 
had to track down a segfault: 
https://issues.dlang.org/show_bug.cgi?id=20868


More information about the Digitalmars-d mailing list