[Issue 1257] New: Erroneous warning for ushort = (ushort | ushort)

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jun 4 23:55:30 PDT 2007


http://d.puremagic.com/issues/show_bug.cgi?id=1257

           Summary: Erroneous warning for ushort = (ushort | ushort)
           Product: D
           Version: 1.014
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: clugdbug at yahoo.com.au


void main(){
ushort a = 1;
ushort b = 2;
ushort c = a|b;
}

dmd -w bug.d
warning - bug.d(5): Error: implicit conversion of expression (cast(int)a |
cast(
int)b) of type int to ushort can cause loss of data
-------

This is ridiculous. Logical operations on two operands of the same size should
not be implicitly converted. The code above is _never_ a bug.

This is particularly bad because
int c = a|b;
does _not_ generate a warning, even though it involves a change from unsigned
to signed, _and_ a change of size, and is therefore likely to be a bug!


-- 



More information about the Digitalmars-d-bugs mailing list