http://d.puremagic.com/issues/show_bug.cgi?id=3449
Summary: const and invariant struct members do not behave according to spec Product: D Version: 2.035 Platform: Other OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nob...@puremagic.com ReportedBy: bugzi...@kyllingen.net --- Comment #0 from Lars T. Kyllingstad <bugzi...@kyllingen.net> 2009-10-29 04:52:34 PDT --- When struct members are declared const or invariant, they seem to become manifest constants. Example: struct Foo { const int bar = 123; } writeln(Foo.sizeof); // Prints "1", not "4" Foo foo; auto p = &foo.bar; // Error: constant 123 is not an lvalue The same happens if const is replaced with immutable. According to the spec it should be possible to take the address of const/immutable variables, and in the case of const it is even considered well-defined behaviour to change their value after casting them to non-const. I see no reason why this shouldn't apply to structs as well. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------