Allow designated initialization of struct

IchorDev zxinsworld at gmail.com
Fri Nov 8 20:20:19 UTC 2024


On Saturday, 2 November 2024 at 20:21:57 UTC, Nick Treleaven 
wrote:
> On Saturday, 2 November 2024 at 18:01:45 UTC, IchorDev wrote:
>> ```d
>> short x = 127;
>> short y = x / 2 + 1; //Error: integer promotion screwed you 
>> over again!
>
> Actually that example compiles fine due to VRP.
> https://dlang.org/spec/type.html#vrp

Which shouldn’t be relied on to prevent integer under/overflow 
because it allows it.
```d
     short x = short.max;
     short div = 1;
     short y = x / div + 1;
```
I thought the point of requiring a cast after promotion was 
preventing under/overflow.


More information about the dip.ideas mailing list