digitalmars.D.bugs - [Issue 6750] New: Explicit template instantiation with auto ref
- d-bugmail puremagic.com (57/57) Sep 30 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6750
http://d.puremagic.com/issues/show_bug.cgi?id=6750 Summary: Explicit template instantiation with auto ref Product: D Version: D2 Platform: x86_64 OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: marcianx gmail.com --- Comment #0 from marcianx gmail.com 2011-09-30 18:51:55 PDT --- I tried this on the DMD64 D compiler v2.055 on linux. The valid D code at the bottom fails with the following errors when I invoke ---------- $ dmd template_autoref_bug.d template_autoref_bug.d(3): Error: auto can only be used for template function parameters ---------- I found three independent ways to suppress this bug (mentioned also in the comments below). 1. I introduce line A. 2. Replace "auto ref" with "const ref". 3. Add a dummy template parameter with default value to the signature of mat_mult_ret() as mentioned in the code comments. The fact that the above workarounds actually work seems to indicate that it is not an error in my understanding of "auto ref", but an actual bug. ---------- struct MatrixT(int M, int N) { } void mat_mult_ret(int M,int N,int P)( auto ref MatrixT!(M,N) A, auto ref MatrixT!(N,P) B, ref MatrixT!(M,P) ret) { } void main(string[] args) { MatrixT!(2,2) mat22; MatrixT!(3,2) mat32; MatrixT!(2,3) mat23; // Line B by itself => compiler says: // template_autoref_bug.d(3): Error: auto can only be used for // template function parameters // To suppress bug (any one works): // * Lines A and B together => no error // * Line A by itself => no error // * Replace "auto ref" with "const ref" // * Add dummy parameter to signature of function: // void mat_mult_ret(int M,int N,int P, dum=void)(...) {...} //mat_mult_ret(mat23, mat32, mat22); // line A mat_mult_ret!(2,3,2)(mat23, mat32, mat22); // line B } ---------- -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 30 2011