www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22735] New: __builtins.di does not implement

https://issues.dlang.org/show_bug.cgi?id=22735

          Issue ID: 22735
           Summary: __builtins.di does not implement __builtin_bswap64
                    correctly
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: druntime
          Assignee: nobody puremagic.com
          Reporter: bugzilla digitalmars.com

Reported by https://github.com/ssvb on 
https://github.com/dlang/druntime/pull/3720#issuecomment-1029329002


foobarmod.c

long long foobar()
{
  return __builtin_bswap64(123);
}
testc.c

#include <stdio.h>

long long foobar();

int main()
{
  printf("%llx\n", foobar());
  return 0;
}
testd.d

import std.stdio, foobarmod;

void main()
{
  writefln("%x", foobar());
}
Compile and run (on a 64-bit linux system):

$ ./dmd testd.d foobarmod.c && ./testd 
7b000000

$ gcc testc.c foobarmod.c && ./a.out
7b00000000000000
The results differ and this isn't good.

--
Feb 03 2022