-preview=in might break code

Walter Bright newshound2 at digitalmars.com
Fri Oct 2 23:44:51 UTC 2020


On 10/2/2020 4:03 PM, Steven Schveighoffer wrote:
> On 10/2/20 6:11 PM, Walter Bright wrote:
>> On 10/2/2020 10:31 AM, Steven Schveighoffer wrote:
>>> And this might not be true on a different compiler.
>>
>> This is looking like a serious problem.
> 
> I was wrong about this case, because it's a dynamic array (which is specifically 
> carved out as an exception). Indeed, there seem to be quite a few exceptions 
> carved out, presumably to make existing code behave reasonably.

Having a struct wrap a dynamic array comes to mind:

     struct A { int[] a; }

vs:

     int[] b;

Having these have different function calling ABIs is something I've tried to 
avoid. I.e. a wrapped type should have the same ABI as the type. Before this, it 
was true.

> 
> But this could be true for another type that isn't in the exception categories. 
> Potentially, a compiler can decide to make the following not true, while others 
> say it is true:
> 
> alias A = void delegate(in long);
> alias B = void delegate(const long);
> 
> static assert(is(A : B));

It's not looking good.


More information about the Digitalmars-d mailing list