Bug 12278 – __traits(classInstanceSize) returns wrong value if used before class is declared

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-02-28T10:21:00Z
Last change time
2014-03-02T19:30:43Z
Keywords
pull
Assigned to
nobody
Creator
destructionator

Comments

Comment #0 by destructionator — 2014-02-28T10:21:05Z
class Foo { InPlace!Bar inside; } class Bar { } struct InPlace(T) { pragma(msg, __traits(classInstanceSize, T)); private byte[__traits(classInstanceSize, T)] rawData; void initializeObject() { pragma(msg, __traits(classInstanceSize, T)); } } dmd bug.d 0u 8u The first one, where the static array is declared, gives 0. The correct value of 8 is given inside the function. If you move `class Bar{}` to above Foo's definition, it correctly gives 8 at both msgs.
Comment #1 by dlang-bugzilla — 2014-03-02T16:15:26Z
Comment #2 by github-bugzilla — 2014-03-02T19:29:44Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/6557ba3d48ef9e29101c09e52304a3a16c2e81a6 fix Issue 12278 - __traits(classInstanceSize) returns wrong value if used before class is declared https://github.com/D-Programming-Language/dmd/commit/9e68f5d3cd9953d34a3944a80faaddbd5f1ef841 Merge pull request #3348 from CyberShadow/fix12278 fix Issue 12278 - __traits(classInstanceSize) returns wrong value if used before class is declared