dip1000 and preview in combine to cause extra safety errors

John Colvin john.loughran.colvin at gmail.com
Wed Jun 8 16:32:25 UTC 2022


On Wednesday, 8 June 2022 at 16:16:37 UTC, deadalnix wrote:
> On Wednesday, 8 June 2022 at 16:01:55 UTC, John Colvin wrote:
>> E.g. this prints `["o", "o", "o", "o", "o"]` regardless of 
>> compiler flags
>>
>>     string foo(scope string s)
>>     {
>>         return s;
>>     }
>>
>>     void main()
>>     {
>>         import std.stdio;
>>         string[] result;
>>         foreach(c; "hello")
>>         {
>>             result ~= foo([c]);
>>         }
>>         writeln(result);
>>     }
>
> There is no frame of reference in which this result is in any 
> way reasonable.

My guess is that technically `foo` has undefined behaviour.


More information about the Digitalmars-d mailing list