[Issue 4436] Double bug regarding Tuple.init

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed May 30 18:53:13 PDT 2012


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



--- Comment #1 from Kenji Hara <k.hara.pg at gmail.com> 2012-05-30 18:55:00 PDT ---
(In reply to comment #0)
> Consider:
> 
> import std.stdio, std.typecons;
> 
> struct S
> {
>     this(this) { writeln("making a copy"); }
> }
> 
> void main() {
>     Tuple!(S, int) x;
>     auto p1 = &(x.init);
>     //auto p2 = &(Tuple!(S, int).init);
> }
> 
> The program as is calls the copy constructor of S twice. It should call none
> (for at least two reasons: effciency and the fact that some types want to
> disable copying).
> 
> Furthermore, uncommenting the last line in main yields a compile-time error. It
> should compile and run (again without invoking the copy constructor).

>From 2.059, T.init always returns rvalue even if T is struct.
So getting address of init property by & operator is rejected in compile.

I think this issue should be closed with the status "resolved invalid".

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