gtbercea marked an inline comment as done.
gtbercea added inline comments.

================
Comment at: lib/Headers/__clang_cuda_cmath.h:55-56
+#if defined(_OPENMP) && defined(__cplusplus)
+__DEVICE__ const float abs(const float __x) { return ::fabsf((float)__x); }
+__DEVICE__ const double abs(const double __x) { return ::fabs((double)__x); }
+#endif
----------------
tra wrote:
> Where do these functions come from?  
> https://en.cppreference.com/w/cpp/numeric/math/fabs does not seem to show any 
> `abs` functions with const args.
What's happening is that when including the random header file, this header 
file uses abs with const arguments:


```
                    const double __n = _M_nd(__urng);
                    const double __y = -std::abs(__n) * __param._M_sm - 1;
```

And without there functions here the error I get is:


```
In file included from test.c:8:
In file included from 
/usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/random:52:
/usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/bits/random.tcc:1476:27:
 error: call to 'abs' is ambiguous
                    const double __y = -std::abs(__n) * __param._M_sm - 1;
                                        ^~~~~~~~
/usr/include/stdlib.h:770:12: note: candidate function
extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
           ^
/usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:166:3:
 note: candidate function
  abs(long __i) { return __builtin_labs(__i); }
  ^
/usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:174:3:
 note: candidate function
  abs(long long __x) { return __builtin_llabs (__x); }
  ^
/usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:179:3:
 note: candidate function
  abs(__int128 __x) { return __x >= 0 ? __x : -__x; }
  ^
```


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62046/new/

https://reviews.llvm.org/D62046



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to