digitalmars.D.bugs - <empty static array>.ptr
- Thomas Kuehne (15/15) Dec 01 2004 -----BEGIN PGP SIGNED MESSAGE-----
- Simon Buchan (20/35) Dec 02 2004 Isn't this expected? Static arrays (as in, type[const] foo;) are
- Thomas Kuehne (12/21) Dec 03 2004 -----BEGIN PGP SIGNED MESSAGE-----
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 NotDashEscaped: You need GnuPG to verify this message the ptr of empty static arrays doesn't point to "null". for dynamic arrays ptr points to "null". test cases: http://svn.kuehne.cn/dstress/run/ptr_03.d http://svn.kuehne.cn/dstress/run/ptr_04.d Thomas -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.9.12 (GNU/Linux) iD8DBQFBrbQ53w+/yD4P9tIRAjrqAJ9aw1QQYiZRTwZW6zIrnv0xsnc4oACgnc4Q KPdALh85aEwutB5X4dZC0qc= =IcQ4 -----END PGP SIGNATURE-----
Dec 01 2004
On Wed, 1 Dec 2004 13:08:25 +0100, Thomas Kuehne <thomas-dloop kuehne.thisisspam.cn> wrote:-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 NotDashEscaped: You need GnuPG to verify this message the ptr of empty static arrays doesn't point to "null". for dynamic arrays ptr points to "null". test cases: http://svn.kuehne.cn/dstress/run/ptr_03.d http://svn.kuehne.cn/dstress/run/ptr_04.d Thomas -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.9.12 (GNU/Linux) iD8DBQFBrbQ53w+/yD4P9tIRAjrqAJ9aw1QQYiZRTwZW6zIrnv0xsnc4oACgnc4Q KPdALh85aEwutB5X4dZC0qc= =IcQ4 -----END PGP SIGNATURE-----Isn't this expected? Static arrays (as in, type[const] foo;) are on the stack by definition, therefore have a ptr. Dynamic arrays are allocated, and (for C compatibilty?) are null'ed when set to length 0. (I know you know this, btw, just asking why this surprises you) If you read std.stream's buffered stream class, you can see Walter has kept the buffer array with at least 1 value so it keeps an address. (Again, for some arcane reason) -- "Unhappy Microsoft customers have a funny way of becoming Linux, Salesforce.com and Oracle customers." - www.microsoft-watch.com: "The Year in Review: Microsoft Opens Up" "Changes/Additions -------------------------------------------------------------------------------- HL2DM released! " - HL2DM changelog - ME
Dec 02 2004
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Simon Buchan schrieb am Donnerstag, 2. Dezember 2004 16:35:On Wed, 1 Dec 2004 13:08:25 +0100, Thomas Kuehne <thomas-dloop kuehne.thisisspam.cn> wrote:the ptr of empty static arrays doesn't point to "null". for dynamic arrays ptr points to "null".Isn't this expected? Static arrays (as in, type[const] foo;) are on the stack by definition, therefore have a ptr. Dynamic arrays are allocated, and (for C compatibilty?) are null'ed when set to length 0. (I know you know this, btw, just asking why this surprises you)I somehow mixed mixed up pointer to pointer and static arrays... Thanks, I fixed the test case. Thomas -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.9.12 (GNU/Linux) iD8DBQFBsG1b3w+/yD4P9tIRAhrNAJwPpLw1MtXBIo8LyPY74hIv+5V6FQCfbTNP +CmzE62LPEbMWL0koVVA/Vk= =jw2I -----END PGP SIGNATURE-----
Dec 03 2004