[Issue 3841] New: silent implicit cast from floating point to integral in += etc. operators

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Feb 22 10:28:48 PST 2010


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

           Summary: silent implicit cast from floating point to integral
                    in += etc. operators
           Product: D
           Version: unspecified
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: andrei at metalanguage.com


--- Comment #0 from Andrei Alexandrescu <andrei at metalanguage.com> 2010-02-22 10:28:45 PST ---
void main() {
    uint a;
    float b = 0.1;
    a += b;
}

This program compiles no problem. This is obviously a problem and a very
surprising behavior; I'm at the end of a 2-hours bug chasing and tried this
only after I eliminated all other opportunities for error.

For numeric types, It is ok for built-in += to perform narrowing conversion,
but not truncating ones.

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


More information about the Digitalmars-d-bugs mailing list