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