[Issue 4203] New: Const field of struct that contains a whole struct

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue May 18 04:08:13 PDT 2010


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

           Summary: Const field of struct that contains a whole struct
           Product: D
           Version: future
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2010-05-18 04:08:11 PDT ---
I don't understand what's going on here, but even if this is not a bug (and to
me it looks like a problem) it's too much tricky for D newbies.

This runs with dmd v2.046:


// case 1
struct Foo {
    const Foo f = Foo();
}
static assert(Foo.sizeof == 1);
void main() {}



While this is not OK:


// case 2
struct Foo {
    const Foo f;
}
static assert(Foo.sizeof == 1);
void main() {}


dmd v2.046 prints:
test.d(2): Error: struct test.Foo cannot have field f with same struct type
test.d(2): Error: struct test.Foo cannot have field f with same struct type

-- 
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