[Issue 4247] Cannot create default-constructed struct on heap when constructor is defined
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Apr 15 07:09:08 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=4247
Maksim Zholudev <maximzms at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |maximzms at gmail.com
--- Comment #8 from Maksim Zholudev <maximzms at gmail.com> 2013-04-15 07:09:04 PDT ---
(In reply to comment #0)
> So the auto s = new S is no longer usable. However, I can easily declare a
> struct S on the stack, or create a new array of S. In fact, you can do:
>
> auto s = (new S[1])[0];
>
> and achieve the desired effect, but this is oh so ugly.
This code would create structure on the heap and put COPY of it to `s`.
It is not the same as `auto s = new S`.
The workaround should be:
--------------------
auto s = (new S[1]).ptr;
--------------------
--
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