www.digitalmars.com         C & C++   DMDScript  

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

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: andrei metalanguage.com


--- Comment #0 from Andrei Alexandrescu <andrei 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: -------
Feb 22 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3841


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid
                 CC|                            |clugdbug yahoo.com.au
            Version|unspecified                 |1.00
           Severity|normal                      |major


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 27 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3841



--- Comment #1 from Andrei Alexandrescu <andrei metalanguage.com> 2010-04-27
11:53:59 PDT ---
Hell yeah it is major. Thanks Don.

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