digitalmars.D.bugs - [Issue 5686] New: class template error
- d-bugmail puremagic.com (35/35) Mar 02 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5686
- d-bugmail puremagic.com (19/19) Mar 03 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5686
- d-bugmail puremagic.com (11/11) Mar 03 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5686
- d-bugmail puremagic.com (15/17) Mar 03 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5686
- d-bugmail puremagic.com (9/9) Mar 03 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5686
- d-bugmail puremagic.com (19/19) Mar 03 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5686
- d-bugmail puremagic.com (24/24) Mar 03 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5686
- d-bugmail puremagic.com (11/11) Mar 19 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5686
- d-bugmail puremagic.com (12/12) Mar 20 2012 http://d.puremagic.com/issues/show_bug.cgi?id=5686
http://d.puremagic.com/issues/show_bug.cgi?id=5686 Summary: class template error Product: D Version: D2 Platform: Other OS/Version: Windows Status: NEW Severity: regression Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: changlon gmail.com test.d -------------------------- ptrdiff_t Test1( string file = __FILE__, ptrdiff_t line = __LINE__)(){ static assert( line != __LINE__ -1 ); return line ; } class Test2(string name, string file = __FILE__, ptrdiff_t line = __LINE__){ static assert( line != __LINE__ -1 ); int i = 1; this(){ } } void main(){ auto test1 = Test1(); auto test2 = new Test2!("test") ; } --------------------------------- test.d(8): Error: static assert (7 != 7) is false test.d(17): instantiated from here: Test2!("test") -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 02 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5686 update test case: ----------------- class Test2(string name, string file = __FILE__, ptrdiff_t line = __LINE__){ static assert( line != __LINE__ -1 ); ptrdiff_t test( string file = __FILE__, ptrdiff_t line = __LINE__)(){ static assert( line != __LINE__ -1 ); return line ; } } void main(){ auto test2 = new Test2!("test") ; test2.test ; } ------------------------------- -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 03 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5686 06:31:04 PST --- Can you be more specific what is the problem? 7 != 7 *is* false. In the static assert line (line 8), __LINE__ should be 8, and line should be 7, since the previous line contains the declaration of line. Are you saying that __LINE__ should be the line number of the instantiation (i.e. 17)? Not sure what the intended behavior is here. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 03 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5686 Steven Schveighoffer <schveiguy yahoo.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |schveiguy yahoo.com 06:36:13 PST ---In the static assert line (line 8), __LINE__ should be 8, and line should be 7, since the previous line contains the declaration of line.Wow, that was confusing :) Let's call the template parameter lineno. I'll try again: In the static assert line (line 8), __LINE__ should be 8, and lineno should be 7, since the previous line contains the declaration of lineno. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 03 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5686 The lineno shoule be the lineno where template is be instantiated, not where it be declared . for template and function template it is working . for class template and class member template it is not working . -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 03 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5686 ----------------------------------- ptrdiff_t Test1( string file = __FILE__, ptrdiff_t line = __LINE__)(){ pragma(msg, line.stringof); return line ; } class Test2(string name, string file = __FILE__, ptrdiff_t line = __LINE__){ pragma(msg, line.stringof); } void main(){ auto test1 = Test1(); auto test2 = new Test2!("test") ; } --------------------------------------- compile this the dmd print 11, 7. dmd should print 11, 12 . -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 03 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5686 07:16:34 PST --- With some testing, I discovered that it's the act of explicit instantiation that causes the line number to be tied to the declaration line: ptrdiff_t Test1(string name, string file = __FILE__, ptrdiff_t line = __LINE__)(){ pragma(msg, line.stringof); return line ; } void main(){ auto test1 = Test1!("test")(); } prints 1. This workaround does work: Test2!(file, line) createTest2(string file = __FILE__, ptrdiff_t line = __LINE__)() { return new Test2!(file line); } I agree with the request that the line number and file should be tied to the instantiation line, not the declaration line. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 03 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5686 Don <clugdbug yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |clugdbug yahoo.com.au Severity|regression |normal This isn't a regression. It didn't work in DMD2.000 either. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 19 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5686 dawg dawgfoto.de changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |dawg dawgfoto.de Resolution| |DUPLICATE *** This issue has been marked as a duplicate of issue 4018 *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 20 2012