microsoft / mimalloc

mimalloc is a compact general purpose allocator with excellent performance.
MIT License
10.6k stars 865 forks source link

error: 'mi_posix_memalign' is missing exception specification 'noexcept' #794

Open sergio-nsk opened 1 year ago

sergio-nsk commented 1 year ago

Environment

macOS 10.13, Xcode AppleClang 10.0.0, -std=c++17 -fno-exceptions -stdlib=libc++ macOS 12, Xcode AppleClang 13.1.6, -std=c++17 -fno-exceptions -stdlib=libc++ mimalloc v2.1.2

Details

After all macro expansions, mi_posix_memalign is declared like

int mi_posix_memalign(void** p, size_t alignment, size_t size) noexcept;

and this substitutes clang posix_memalign and conflicts with it, that seems to be declared without noexcept:

extern "C" int posix_memalign(void **__memptr, size_t __alignment, size_t __size);

The whole error message:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/13.1.6/include/mm_malloc.h:25:16: error: 'mi_posix_memalign' is missing exception specification 'noexcept'
extern "C" int posix_memalign(void **__memptr, size_t __alignment, size_t __size);
               ^
/Users/buildbox/Source/actions-runner/_work/client/client/core/../third_party/mimalloc/include/mimalloc-override.h:54:33: note: expanded from macro 'posix_memalign'
#define posix_memalign(p,a,n)   mi_posix_memalign(p,a,n)
                                ^
/Users/buildbox/Source/actions-runner/_work/client/client/core/../third_party/mimalloc/include/mimalloc.h:383:20: note: previous declaration is here
mi_decl_export int mi_posix_memalign(void** p, size_t alignment, size_t size)   mi_attr_noexcept;
                   ^
FrothyB commented 6 months ago

Have just run into this as well on Linux with clang 17, any workaround?

EDIT: for what it's worth, simply removing the mi_attr_noexcept from the definition appears to work, obviously not a satisfactory long term solution.