no-argument constructor: is this a bug?
Jonathan M Davis
jmdavisProg at gmx.com
Sun Jan 22 16:16:51 PST 2012
On Sunday, January 22, 2012 17:51:36 Caligo wrote:
> struct A(uint samples){
>
> float[samples] _data = void;
>
> this(float val = 0.0f){ fill(_data[], val); }
> }
>
>
> auto a = A!8();
>
> a._data is filled with garbage instead of zeros because the
> no-argument constructor is called instead of the one that I've
> defined.
http://d.puremagic.com/issues/show_bug.cgi?id=3438
It should be illegal to have a struct constructor where all of its parameters
have default arguments. If you want to have all default arguments, then use
static opCall instead.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list