Bug 6488 – DMD compiler bug

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2011-08-12T19:01:00Z
Last change time
2011-10-18T10:18:19Z
Assigned to
nobody
Creator
soarowl

Comments

Comment #0 by soarowl — 2011-08-12T19:01:38Z
When I compile tools\rdmd.d with following options: dmd -inline -J. -noboundscheck -nofloat -O -release rdmd.d Compiler has this error: Error: template core.time.TickDuration.to(string units,T) if ((units == "seconds" || units == "msecs" || units == "usecs" || units == "hnsecs" || units == "nsecs") && (__traits(isIntegral,T) && T.sizeof >= 4)) cannot deduce template function from argument types !("seconds",long)() But if I compile rdmd.d with those options, all fine: dmd -inline -J. -nofloat -O -release rdmd.d dmd -J. -noboundscheck -nofloat -O -release rdmd.d dmd -inline -J. -noboundscheck -nofloat -O rdmd.d
Comment #1 by r.sagitario — 2011-10-02T02:56:57Z
A similar error happens if you try to compile time.di directly: >dmd -c -o- c:\l\dmd-2.055\src\druntime\import\core\time.di c:\l\dmd-2.055\src\druntime\import\core\time.di(253): Error: template core.time. TickDuration.to(string units,T) if ((units == "seconds" || units == "msecs" || u nits == "usecs" || units == "hnsecs" || units == "nsecs") && (__traits(isIntegra l,T) && T.sizeof >= 4)) does not match any function template declaration c:\l\dmd-2.055\src\druntime\import\core\time.di(253): Error: template core.time. TickDuration.to(string units,T) if ((units == "seconds" || units == "msecs" || u nits == "usecs" || units == "hnsecs" || units == "nsecs") && (__traits(isIntegra l,T) && T.sizeof >= 4)) cannot deduce template function from argument types !("s econds",long)() In time.di, the to template functions have been converted to eponymous templates, which seems to trigger the error in combination with qualifiers. Here is a reduced test case: struct TickDuration { template to(T) if (__traits(isIntegral,T)) { const T to() { return 1; } } template to(T) if (__traits(isFloating,T)) { const T to() { return 0; } } const long seconds() // line 21 { return to!(long)(); } } void main() { TickDuration d; d.seconds(); } >dmd test.d test.d(21): Error: template test.TickDuration.to(T) if (__traits(isIntegral,T)) does not match any function template declaration test.d(21): Error: template test.TickDuration.to(T) if (__traits(isIntegral,T)) cannot deduce template function from argument types !(long)() The error disappears if you remove the const qualifier from seconds() or if you remove the second template.
Comment #2 by bugzilla — 2011-10-18T10:16:58Z
Comment #3 by bugzilla — 2011-10-18T10:18:19Z
*** Issue 6502 has been marked as a duplicate of this issue. ***