[Joke] C++ and D namings

Steven Schveighoffer schveiguy at gmail.com
Wed Jan 20 15:17:09 UTC 2021


On 1/20/21 10:13 AM, Paul Backus wrote:
> On Wednesday, 20 January 2021 at 14:33:11 UTC, Steven Schveighoffer wrote:
>> Your immutable case would ALWAYS be UB, but only if you accessed the 
>> member you didn't set.
>>
>> And again, disallowed in @safe code.
> 
> This version compiles even with @safe:
> 
> import std.stdio;
> union t {int x; immutable int y;};
> void main() @safe
> {
> 
>      t a = { x: 0 };
>      writeln(a.y);
>      t b = { y: 4 };
>      a = b; // oops
>      writeln(a.y);
> }

That seems like a bug. Writing the x directly fails in @safe code.

-Steve


More information about the Digitalmars-d mailing list