www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22083] New: Error: function

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

          Issue ID: 22083
           Summary: Error: function
                    ldc.intrinsics.llvm_bswap!uint.llvm_bswap conflict
                    with
                    std.bitmanip.nativeToBigEndian!ushort.nativeToBigEndia
                    n
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: mingwu gmail.com

kinke think this is a frontend bug, only showing in LDC:

https://github.com/ldc-developers/ldc/issues/3772

=================================================
Hi,

While building apache-thrift, LDC has build failure (DMD succeed):

/home/./.dub/packages/apache-thrift-0.14.1/apache-thrift/lib/d/src/thrift/transport/websocket.d(335,39):
Error: function ldc.intrinsics.llvm_bswap!uint.llvm_bswap at
/home/./project/ldc2-1.26.0-linux-x86_64/bin/../import/ldc/intrinsics.di(405,7)
conflicts with function std.bitmanip.nativeToBigEndian!ushort.nativeToBigEndian
at
/home/./project/ldc2-1.26.0-linux-x86_64/bin/../import/std/bitmanip.d(2998,6)

While there is a work around by using fully qualified names:
std.bitmanip.nativeToBigEndian, I think LDC compiler should be fixed.

$ ldc2 --version
LDC - the LLVM D compiler (1.26.0):
  based on DMD v2.096.1 and LLVM 11.0.1
  built with LDC - the LLVM D compiler (1.26.0)
  Default target: x86_64-unknown-linux-gnu
  Host CPU: znver1
  http://dlang.org - http://wiki.dlang.org/LDC



This looks like a frontend bug - the conflict seems to be caused by
https://github.com/ldc-developers/phobos/blob/16d1a9be59cb319961bd7bc0bcd1128151fc0a67/st
/digest/sha.d#L124, 
```
version (LittleEndian)
{
    private alias nativeToBigEndian = bswap;
    private alias bigEndianToNative = bswap;
}
```

which is a private alias, which - for LDC - aliases 2 other aliases: 

https://github.com/ldc-developers/druntime/blob/8916695501005be33291f5a88e399b7eb1eb9e25/src/core/bitop.d#L657
and 
```
version (LDC)
{
    alias bswap = llvm_bswap!uint;
}
```


https://github.com/ldc-developers/druntime/blob/8916695501005be33291f5a88e399b7eb1eb9e25/src/core/bitop.d#L677
```
version (LDC)
{
    alias bswap = llvm_bswap!ulong;
}
```

=================================

I wasn't able to reduce it to a smaller test case; maybe someone who is more
familiar with the frontend code can do.

--
Jun 24 2021