[Issue 3449] const and invariant struct members do not behave according to spec

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jan 23 01:39:59 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=3449


Walter Bright <bugzilla at digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|spec                        |


--- Comment #10 from Walter Bright <bugzilla at digitalmars.com> 2012-01-23 01:39:58 PST ---
(In reply to comment #0)
> 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

Taking the address should work. Compiler bug, not a spec issue.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list