Bug 772 – Bogus error using relation operator as static if expression within template

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-12-30T00:42:00Z
Last change time
2014-02-15T13:22:24Z
Assigned to
bugzilla
Creator
ibisbasenji

Comments

Comment #0 by ibisbasenji — 2006-12-30T00:42:44Z
Given the following useless test program... -------------------------------------------------- module bug ; template foo (ulong n) { static if (n < 10_LU) { const foo = n ; } else { const foo = n % 10 ; } } void main () { ulong a = 1_LU ; auto omega = foo!(a); } -------------------------------------------------- The compiler will output: bug.d(4): Error: expression (a) < 10LU does not evaluate to a boolean bug.d(15): template instance bool0.main.foo!(a) error instantiating
Comment #1 by thomas-dloop — 2006-12-31T08:47:49Z
Comment #2 by bugzilla — 2007-01-03T22:54:35Z
Fixed DMD 1.00
Comment #3 by davidl — 2008-07-24T08:57:44Z
seems regression on dmd 1.033
Comment #4 by gide — 2008-11-08T12:34:40Z
const should be added to the variable declaration, so the error message is correct. Add const and it works in DMD 2.020 and 1.033. module bug ; template foo (ulong n) { static if (n < 10_LU) { const foo = n ; } else { const foo = n % 10 ; } } void main () { const ulong a = 1_LU ; // <- added const auto omega = foo!(a); }