[Issue 4247] Cannot create default-constructed struct on heap when constructor is defined

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Sep 11 07:11:25 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4247


nfxjfg at gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nfxjfg at gmail.com


--- Comment #3 from nfxjfg at gmail.com 2010-09-11 07:10:59 PDT ---
(In reply to comment #1)
> Also, since when are structs allowed to be allocated on the heap? TDPL
> explicitly states that structs have scoped lifetime.

If structs couldn't be allocated on the heap, you'd have to forget about struct
arrays. And this is pure bullshit. E.g. this wouldn't be allowed anymore:

S[] array;
array.length = 1;

You couldn't seriously want this to be illegal.

(This code snippet also shows that it's advantageous to force structs having a
"simple" default ctor, i.e. one that doesn't require the runtime to run code on
each element to construct it.)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list