www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22744] New: ImportC: builtins defined in __builtins.di cause


          Issue ID: 22744
           Summary: ImportC: builtins defined in __builtins.di cause
                    undefined symbol linker errors.
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Mac OS X
            Status: NEW
          Keywords: ImportC
          Severity: normal
          Priority: P1
         Component: druntime
          Assignee: nobody puremagic.com
          Reporter: dave287091 gmail.com

`__builtin_inf()`, `__builtin_inff()` and `__builtin_infl()` will result in an
undefined symbol error if used in C code. For example:

// test.c
static inline
int isfinite(float x){
    return x == x && __builtin_fabsf(x) != __builtin_inff();

int main(){
    return isfinite(3.2f);

$ dmd test.c
Undefined symbols for architecture x86_64:
  "__D10__builtins14__builtin_inffFZf", referenced from:
      _isfinite in test.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Error: linker exited with status 1

Feb 07 2022