Compiler bug? Addition/subtraction code

Era Scarecrow via D.gnu d.gnu at puremagic.com
Mon Jun 19 19:14:06 PDT 2017


On Tuesday, 20 June 2017 at 01:58:22 UTC, Era Scarecrow wrote:
>    long t;    //temporary, doubles as carry
>    <snip>
>         t >>= uint.sizeof*8;


  To note, looking in compiler explorer (GDC 5.2.0), the following 
output is present (for the above line):

         mov     rax, QWORD PTR [rbp-24]
         shr     rax, 32
         mov     QWORD PTR [rbp-24], rax

  'shr' is unsigned right shift, when it should be 'sar' signed 
right shift. That is my guess where the bug is.


More information about the D.gnu mailing list