Thread overview
[Issue 5417] New: Integer operations promote too much
Jan 06, 2011
Walter Bright
January 06, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5417

           Summary: Integer operations promote too much
           Product: D
           Version: D2
          Platform: All
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: eatingstaples@gmail.com


--- Comment #0 from eatingstaples@gmail.com 2011-01-05 18:17:38 PST ---
Created an attachment (id=861)
Code with integer promotion

When summing two shorts, they should not be both promoted to int, especially since this reduces the ability to pack things in registers.

I've attached code which demonstrates summing two shorts as they are both promoted to int. The code will not build, with an error explaining that both parameters have been promoted, leading to the expression being of type int rather than short.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 06, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5417


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |INVALID


--- Comment #1 from Walter Bright <bugzilla@digitalmars.com> 2011-01-05 18:42:07 PST ---
This behavior matches C integral promotion rules, which is by design, to make it easy for C programs and programmers to transition to D.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 06, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5417


Andrei Alexandrescu <andrei@metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrei@metalanguage.com


--- Comment #2 from Andrei Alexandrescu <andrei@metalanguage.com> 2011-01-06 06:49:30 PST ---
I'll leave this resolved, but in this case two shorts are summed that are known statically to be zero. Value range propagation should allow the implicit cast back to short.

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