Bug 2550 – implicit conversions don't apply to template value parameter specialization

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2009-01-01T02:19:00Z
Last change time
2015-06-09T05:10:45Z
Keywords
patch, wrong-code
Assigned to
nobody
Creator
davidl

Comments

Comment #0 by davidl — 2009-01-01T02:19:21Z
template pow10(long n) { static if(n<0) const long pow10=0; else const long pow10=10*pow10!(n-1); } template pow10(long n:0) { const long pow10=1; } static assert(pow10!(0) == 1);
Comment #1 by clugdbug — 2009-09-24T07:15:54Z
Original title: 'template specialization not working because of "static if"?' It's not because of 'static if'. This shows the same problem: template pow10(long n){ const long pow10=7; } template pow10(long n:0){ const long pow10=1; } static assert(pow10!(0) == 1); It will compile if you put static assert(pow10!(0L) == 1); It seems that the compiler requires template value specialisations have to exactly match both type and value, but I don't see that in the spec anywhere. Probably a bug. It's certainly pretty annoying.
Comment #2 by clugdbug — 2010-12-01T02:30:22Z
I believe bug 2257 is the same issue.
Comment #3 by k.hara.pg — 2011-12-01T13:42:33Z
D2 patch: https://github.com/D-Programming-Language/dmd/pull/449 This issue is almost same with bug3467.
Comment #4 by k.hara.pg — 2011-12-10T12:08:27Z
*** Issue 7090 has been marked as a duplicate of this issue. ***
Comment #5 by bugzilla — 2011-12-10T16:38:21Z