http://d.puremagic.com/issues/show_bug.cgi?id=5769
Summary: struct elaborate constructor should make rvalue Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nob...@puremagic.com ReportedBy: k.hara...@gmail.com --- Comment #0 from Kenji Hara <k.hara...@gmail.com> 2011-03-23 05:34:02 PDT --- Struct literal/constructor call should make rvalue. Related issue is issue5178. Test code: ---- struct S // has default parameterized constructor { int n; } struct T // has normal constructor { this(int n){} // ref T __ctor(int n){ return this; } // dmd generates internally like this } struct T2 { template __ctor() // workaround { T2 __ctor(int n){ return this; } // return copied rvalue } } // lvalue checker bool checker(T...)(auto ref T t){ return __traits(isRef, t[0]); } import std.stdio; void main() { int n = 20; S s = S(20); T t = T(20); T2 t2 = T2(20); writefln("%s / %s", checker( 10) , checker( n)); // false/true, ok writefln("%s / %s", checker( S(10)), checker( s)); // true /true, NG (Fixed by issue5178 patch) writefln("%s / %s", checker( T(10)), checker( t)); // true /true, NG!!! writefln("%s / %s", checker(T2(10)), checker(t2)); // false/true, ok } ---- -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------