[Joke] C++ and D namings
Paul Backus
snarwin at gmail.com
Wed Jan 20 12:37:41 UTC 2021
On Wednesday, 20 January 2021 at 05:48:28 UTC, Ola Fosheim
Grostad wrote:
> Or worse:
> import std.stdio;
> union t {int x; immutable int y;};
> void main()
> {
>
> t a;
> a.x=3;
> writeln(a.y);
> a.x=4;
> writeln(a.y);
> }
This seems like a bug to me. Especially since the compiler even
allows this:
t b = { y: 4 };
a = b;
Changing "union" to "struct" produces the expected error message:
Error: cannot modify struct instance `a` of type `t` because it
contains `const` or `immutable` members
More information about the Digitalmars-d
mailing list