digitalmars.D.bugs - [Issue 241] New: Template function ICE
- d-bugmail puremagic.com (18/18) Jul 06 2006 http://d.puremagic.com/issues/show_bug.cgi?id=241
 - Oskar Linde (17/40) Jul 06 2006 Upon closer inspection, it appears that using a template TypeParameter
 - Oskar Linde (11/60) Jul 06 2006 Further attempts resulted in issue 242 and found that the following does...
 - Thomas Kuehne (13/19) Jul 07 2006 -----BEGIN PGP SIGNED MESSAGE-----
 - d-bugmail puremagic.com (9/9) Jul 18 2006 http://d.puremagic.com/issues/show_bug.cgi?id=241
 
http://d.puremagic.com/issues/show_bug.cgi?id=241
           Summary: Template function ICE
           Product: D
           Version: 0.162
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: oskar.linde gmail.com
T func(T, T c = 1)(T x) { return x * c; }
void main() { func(1.0); }
Generates (with DMD 0.162 linux):
dmd: template.c:622: void TemplateDeclaration::declareParameter(Scope*,
TemplateParameter*, Object*): Assertion `0' failed.
-- 
 Jul 06 2006
d-bugmail puremagic.com wrote:
 http://d.puremagic.com/issues/show_bug.cgi?id=241
 
            Summary: Template function ICE
            Product: D
            Version: 0.162
           Platform: PC
         OS/Version: Linux
             Status: NEW
           Severity: normal
           Priority: P2
          Component: DMD
         AssignedTo: bugzilla digitalmars.com
         ReportedBy: oskar.linde gmail.com
 
 
 T func(T, T c = 1)(T x) { return x * c; }
 void main() { func(1.0); }
 
 Generates (with DMD 0.162 linux):
 dmd: template.c:622: void TemplateDeclaration::declareParameter(Scope*,
 TemplateParameter*, Object*): Assertion `0' failed.
 
 
Upon closer inspection, it appears that using a template TypeParameter 
type as a value type doesn't work.
Both:
func!(double)(1.0);
and
func!(double,1)(1.0);
give: "template instance [...] does not match any template declaration"
I would expect
template(T,T c) {...}
to work for any T such that T is a valid value type, and in other cases 
generate an error message on instantiation saying something like "T is 
not a valid template value type".
If, on the other hand, the use of a template type as value parameter 
type is not meant to be allowed, an error message on template 
declaration would be helpful.
/Oskar
 Jul 06 2006
Oskar Linde wrote:d-bugmail puremagic.com wrote:Further attempts resulted in issue 242 and found that the following does work: template func(T) { template f(T c = 1)(T x) { return c*x; } } void main() { func!(double).f(5.0); // OK func!(double).f!(2.0)(5.0); // OK } /Oskarhttp://d.puremagic.com/issues/show_bug.cgi?id=241 Summary: Template function ICE Product: D Version: 0.162 Platform: PC OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: oskar.linde gmail.com T func(T, T c = 1)(T x) { return x * c; } void main() { func(1.0); } Generates (with DMD 0.162 linux): dmd: template.c:622: void TemplateDeclaration::declareParameter(Scope*, TemplateParameter*, Object*): Assertion `0' failed.Upon closer inspection, it appears that using a template TypeParameter type as a value type doesn't work. Both: func!(double)(1.0); and func!(double,1)(1.0); give: "template instance [...] does not match any template declaration" I would expect template(T,T c) {...} to work for any T such that T is a valid value type, and in other cases generate an error message on instantiation saying something like "T is not a valid template value type". If, on the other hand, the use of a template type as value parameter type is not meant to be allowed, an error message on template declaration would be helpful. /Oskar
 Jul 06 2006
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 d-bugmail puremagic.com schrieb am 2006-07-06:http://d.puremagic.com/issues/show_bug.cgi?id=241T func(T, T c = 1)(T x) { return x * c; } void main() { func(1.0); } Generates (with DMD 0.162 linux): dmd: template.c:622: void TemplateDeclaration::declareParameter(Scope*, TemplateParameter*, Object*): Assertion `0' failed.Added to DStress as http://dstress.kuehne.cn/run/b/bug_template_622_A.d http://dstress.kuehne.cn/run/b/bug_template_622_B.d http://dstress.kuehne.cn/run/b/bug_template_622_C.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFErkkPLK5blCcjpWoRAjlyAJ0YlSkOiUS7B/4or7smStmAfahBaQCeIVFH d0U7OoDuoMmndj5HyGWyGx8= =mScX -----END PGP SIGNATURE-----
 Jul 07 2006
http://d.puremagic.com/issues/show_bug.cgi?id=241
jpelcis gmail.com changed:
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
Fixed DMD 0.163.
-- 
 Jul 18 2006








 
 
 
 Oskar Linde <oskar.lindeREM OVEgmail.com> 