digitalmars.D.bugs - [Bug 44] New: forward referenced anonymous union in struct size discrepancy
- d-bugmail puremagic.com (32/32) Mar 12 2006 http://d.puremagic.com/bugzilla/show_bug.cgi?id=44
- Thomas Kuehne (18/31) Mar 13 2006 -----BEGIN PGP SIGNED MESSAGE-----
- d-bugmail puremagic.com (9/9) May 25 2006 http://d.puremagic.com/bugzilla/show_bug.cgi?id=44
http://d.puremagic.com/bugzilla/show_bug.cgi?id=44
Summary: forward referenced anonymous union in struct size
discrepancy
Product: D
Version: 0.149
Platform: PC
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla digitalmars.com
ReportedBy: regan netwin.co.nz
If B is declared before A, or the union in A is named (and an instance added)
then the sizeof A is 12 as it should be. In the example below it is 8.
struct A {
int a;
union {
int c;
B b;
}
}
struct B {
int b1;
int b2;
}
void main()
{
A a;
assert(A.sizeof == 12);
}
--
Mar 12 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
d-bugmail puremagic.com schrieb am 2006-03-12:
If B is declared before A, or the union in A is named (and an instance added)
then the sizeof A is 12 as it should be. In the example below it is 8.
struct A {
int a;
union {
int c;
B b;
}
}
struct B {
int b1;
int b2;
}
Added to DStress as
http://dstress.kuehne.cn/run/u/union_16_A.d
http://dstress.kuehne.cn/run/u/union_16_B.d
http://dstress.kuehne.cn/run/u/union_16_C.d
http://dstress.kuehne.cn/run/u/union_16_D.d
http://dstress.kuehne.cn/run/u/union_16_E.d
http://dstress.kuehne.cn/run/u/union_16_F.d
http://dstress.kuehne.cn/run/u/union_16_G.d
http://dstress.kuehne.cn/run/u/union_16_H.d
Thomas
-----BEGIN PGP SIGNATURE-----
iD8DBQFEFS7O3w+/yD4P9tIRAozZAJwKACUIQmALriijrOAxWHfi7NdvzgCbBzOg
sJSwMb7zHxyIEEsqBkcE8qk=
=WLwB
-----END PGP SIGNATURE-----
Mar 13 2006
http://d.puremagic.com/bugzilla/show_bug.cgi?id=44
bugzilla digitalmars.com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
Fixed 0.158
--
May 25 2006









Thomas Kuehne <thomas-dloop kuehne.cn> 