www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1611] New: State-losing implicit conversions are allowed

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1611

           Summary: State-losing implicit conversions are allowed
           Product: D
           Version: 2.007
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: andrei metalanguage.com


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.


-- 
Oct 24 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1611


smjg iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg iname.com
           Severity|normal                      |enhancement
         OS/Version|Linux                       |All
            Summary|State-losing implicit       |State-losing implicit
                   |conversions are allowed     |conversions should not  be
                   |                            |allowed





This is by design, but a bad design I agree.  Changing to enhancement.


-- 
Nov 08 2007
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1611


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED





06:25:12 PDT ---
Fixed in 2.031, however incompletely (see e.g. 3147).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 07 2009