-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Description
Previously, we have been using LLVM 15 to compile to WebAssembly via Emscripten 3.1.38.
Attempting to update to newer Emscripten 4.0.19, which carries an update to LLVM 20.1.4 libcxx, the following code, which used to compile before with the LLVM 15 branch, no longer does:
a.cpp
#include <cmath>
// C23: isfinite() is a macro, so undef it from existence
#ifdef isfinite
#undef isfinite
#endif
namespace math {
int isfinite(float x) {
return ((unsigned int)x & 0x7F800000u) != 0x7F800000u;
}
}
int main() {
using namespace math;
isfinite(1.f);
}This produces an error
a.cpp:16:3: error: call to 'isfinite' is ambiguous
16 | isfinite(1.f);
| ^~~~~~~~
C:\emsdk\emscripten\main\cache\sysroot/include/c++/v1\__math/traits.h:71:83: note: candidate function
71 | [[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(float __x) _NOEXCEPT {
| ^
a.cpp:9:7: note: candidate function
9 | int isfinite(float x) {
| ^
1 error generated.
It looks like the above code stopped compiling after this commit: 7f2bd53
I am not 100% language spec lawyer here.. Is the program a.cpp malformed and the compilation error allowed by the spec?
The C++ standard does not state that a function isfinite() should exist in global scope, but only a std::isfinite() namespaced version should exist? (https://isocpp.org/files/papers/N4860.pdf page 1215 has bool std::isfinite(float x);)
The C23 standard talks about a isfinite() macro (although gives its declaration in a pseudo-function declaration form)
so the above code should not conflict on a global function from the C standard?
Hence, it does seem to me like it would be a regression bug that the above code a.cpp no longer compiles?