Bug 2568 – Warning Inside Template Causes Instantiation Error

Status
RESOLVED
Resolution
INVALID
Severity
minor
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2009-01-08T01:50:00Z
Last change time
2014-03-01T00:36:50Z
Keywords
rejects-valid
Assigned to
nobody
Creator
bus_dbugzilla

Comments

Comment #0 by bus_dbugzilla — 2009-01-08T01:50:41Z
----------------- void foo(T)(T arg) { int i = 999; byte b = i; } void main() { float f; foo(f); } ----------------- The above code compiles correctly with warnings disabled. But when warnings are enabled, an template instantiation error is generated: ----------------- warning - main.d(4): Error: implicit conversion of expression (i) of type int to byte can cause loss of data main.d(10): template instance main_.foo!(float) error instantiating ----------------- This might be related to #2567 and DMD's general treatment of warnings as errors.
Comment #1 by yebblies — 2011-06-10T06:40:33Z
In dmd 1.063 this no longer generates the error, but does cause the warning. The failed compilation is in line with dmd's treatment of errors. The -wi switch has since been introduced for the case you do not want to treat warnings as error.