[Joke] C++ and D namings

Ola Fosheim Grostad ola.fosheim.grostad at gmail.com
Wed Jan 20 05:12:15 UTC 2021


On Wednesday, 20 January 2021 at 05:04:44 UTC, Steven 
Schveighoffer wrote:
> On 1/19/21 11:21 PM, Ola Fosheim Grostad wrote:
> This is undefined behavior in D. How does it lead to different 
> code Gen? This code could pass in D, but the equivalent C++ 
> would have to fail since it's not UB:
>
> int i = 3;
> const int *j = &i;
> *(cast(int *)j) = 4;
> assert(i == 3);

Wasnt D supposed to eliminate UB?

How about this?

union t {int x; const int y;};




More information about the Digitalmars-d mailing list