http://d.puremagic.com/issues/show_bug.cgi?id=3398
Don <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] Summary|Version block inside a |Attributes inside a union |union screws data alignment |screws data alignment Severity|normal |critical --- Comment #1 from Don <[email protected]> 2010-04-21 01:14:12 PDT --- This applies not just to version declarations; it applies to any attribute. union Foo1 { double[2] a; double[2] b; } union Foo2 { public: double[2] a; double[2] b; } static assert(Foo1.sizeof == Foo2.sizeof); --- bug.d(32): Error: static assert (16u == 32u) is false Subtle and disastrous bug (especially when dealing with C libraries), escalating severity. Here's a mitigation to create an error message, rather than generate wrong code. MITIGATION: struct.c StructDeclaration::semantic() line 384. The problem is that AttribDeclaration::semantic has it's own loop for doing the semantic on members, which does NOT include setting the offset to 0 if it's a union. Fixing this would not be difficult, but would require a minor structural change in the compiler. --- for (int i = 0; i < members_dim; i++) { Dsymbol *s = (Dsymbol *)members->data[i]; + if (isUnionDeclaration() && s->isAttribDeclaration()) + error("Attributes don't yet work inside unions, see Bugzilla 3398"); s->semantic(sc2); if (isUnionDeclaration()) sc2->offset = 0; ------- -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
