Bug 1611 – State-losing implicit conversions should not be allowed
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
All
Creation time
2007-10-24T12:16:00Z
Last change time
2015-06-09T01:14:21Z
Assigned to
nobody
Creator
andrei
Comments
Comment #0 by andrei — 2007-10-24T12:16:04Z
In the grand tradition of C, many state-losing conversions among integral types are implicit. This emasculates integral types and allows many bugs go by unnoticed.
The following program should print nothing:
import std.stdio;
import std.typetuple;
void main()
{
alias TypeTuple!(byte, ubyte, short, ushort, int, uint, long, ulong,
char, wchar, dchar)
AllIntegrals;
foreach (T1; AllIntegrals)
{
foreach (T2; AllIntegrals)
{
static if (is(T1 : T2) && T1.sizeof > T2.sizeof)
writeln(T1.stringof, " -> ", T2.stringof);
}
}
}
It currently prints 45 lines.
Comment #1 by smjg — 2007-11-08T15:11:31Z
This is by design, but a bad design I agree. Changing to enhancement.
Comment #2 by andrei — 2009-07-07T06:25:12Z
Fixed in 2.031, however incompletely (see e.g. 3147).