[Issue 8118] Impossible to initialize a member struct without default constructor or assigment

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat May 19 03:42:53 PDT 2012


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


Dmitry Olshansky <dmitry.olsh at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dmitry.olsh at gmail.com


--- Comment #2 from Dmitry Olshansky <dmitry.olsh at gmail.com> 2012-05-19 03:44:28 PDT ---
(In reply to comment #0)
> struct S
> {
>     @disable this();
>     this(int) { }
>     @disable void opAssign(typeof(this));
> }
> 
> class Test
> {
>     S s = void;      // I *EXPLICITLY* told it not to be initialized, but...
>     this() { s = S(to!int("1")); }
> }
> 
> void main() { new Test(); }
> 
> 
> Error: function S.opAssign is not callable because it is annotated with
> @disable
> Error: default construction is disabled for type Test
> 
> 
> 
> Structs without default constructors are pretty much impossible to use.
No bug here you just diabled too much. Undisable opAssign.

It's opAssign that gets called whne a = ... is seen:
this() { s = S(to!int("1")); }
If opAssign is trivial it replaced with bitblit. (that is disable comes first!)

-- 
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