Thread overview
[Issue 19402] specs for promotion rule of shift exp is wrong
[Issue 19402] bitshift with long shift amount results in int instead of long
Feb 14, 2019
Basile-z
Feb 15, 2019
Walter Bright
Feb 15, 2019
Basile-z
Feb 15, 2019
Walter Bright
Jul 17, 2019
Dlang Bot
Jul 25, 2019
Dlang Bot
Mar 21, 2020
Basile-z
February 14, 2019
https://issues.dlang.org/show_bug.cgi?id=19402

Basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
                 CC|                            |b2.temp@gmx.com
           Hardware|x86                         |All
                 OS|Windows                     |All

--- Comment #1 from Basile-z <b2.temp@gmx.com> ---
There are changes required in phobos to apply the spec correctly. Maybe even a deprecation required (in which case i would pass my way).

Attempt for now: https://github.com/dlang/dmd/pull/9361

--
February 15, 2019
https://issues.dlang.org/show_bug.cgi?id=19402

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com

--- Comment #2 from Walter Bright <bugzilla@digitalmars.com> ---
The spec is simply wrong. We need to follow the C conventions here, otherwise people will get nasty unexpected bugs. The C90 rule is:

"The integer promotions are performed on each of the operands. The type of the result is that of the promoted left operand. If the value of the right operand is negative or is greater than or equal to the width of the promoted left operand, the behavior is undefined."

C++98 is pretty much the same:

"The operands shall be of integral or enumeration type and integral promotions are performed.  The type of the result is that of the promoted left operand. The behavior is undefined if the right operand is negative, or greater than or equal to the length in bits of the promoted left operand."

The D behavior is:

        exp.e1 = integralPromotions(exp.e1, sc);
        if (exp.e2.type.toBasetype().ty != Tvector)
            exp.e2 = exp.e2.castTo(sc, Type.tshiftcnt);

which matches the C/C++ behavior. The compiler is right, the spec is wrong.

--
February 15, 2019
https://issues.dlang.org/show_bug.cgi?id=19402

Basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|pull                        |spec
          Component|dmd                         |dlang.org
            Summary|bitshift with long shift    |specs for promotion rule of
                   |amount results in int       |shift exp is wrong
                   |instead of long             |

--
February 15, 2019
https://issues.dlang.org/show_bug.cgi?id=19402

--- Comment #3 from Walter Bright <bugzilla@digitalmars.com> ---
Spec pull:

https://github.com/dlang/dlang.org/pull/2578

--
July 17, 2019
https://issues.dlang.org/show_bug.cgi?id=19402

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #4 from Dlang Bot <dlang-bot@dlang.rocks> ---
@dkorpel created dlang/dlang.org pull request #2682 "fix Issue 19402 - specs for promotion rule of shift exp is wrong (without anything else)" fixing this issue:

- fix Issue 19402 - specs for promotion rule of shift exp is wrong

https://github.com/dlang/dlang.org/pull/2682

--
July 25, 2019
https://issues.dlang.org/show_bug.cgi?id=19402

Dlang Bot <dlang-bot@dlang.rocks> changed:

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

--- Comment #5 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dlang.org pull request #2682 "fix Issue 19402 - specs for promotion rule of shift exp is wrong (without anything else)" was merged into master:

- 67cd903107782b3f9055d40aca61854b590d9482 by dkorpel:
  fix Issue 19402 - specs for promotion rule of shift exp is wrong

https://github.com/dlang/dlang.org/pull/2682

--
March 21, 2020
https://issues.dlang.org/show_bug.cgi?id=19402

Basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|b2.temp@gmx.com             |

--