digitalmars.D.bugs - [Issue 8760] New: for a struct A, new A should work if A a; does
- d-bugmail puremagic.com (38/38) Oct 04 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8760
http://d.puremagic.com/issues/show_bug.cgi?id=8760 Summary: for a struct A, new A should work if A a; does Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: fawzi gmx.ch --- Comment #0 from Fawzi Mohamed <fawzi gmx.ch> 2012-10-04 14:59:20 PDT --- -------- module t2; struct A{ this(int i){} } void f(){ auto a=new A; } --------- fails to compile with dmd 2.060: t2.d(8): Error: constructor t2.A.this (int i) is not callable using argument types () t2.d(8): Error: expected 1 function arguments, not 0 This creates strange problems (for example Variant not working), as a workaround one can give a default argument to the constructor, and then the error is suppressed. As a struct can be default initialized when on the stack (with 'A a;'), it is only logical to expect to be able to allocate it on the heap with 'new A;'. This is related with the discussions in issue3680 and issue3438 , but independently from the larger changes/discussion in there, I think this simple operation should work, only when disable this(){} there should be an error with new A -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 04 2012