microsoft / microsoft/mimalloc

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

Open
#794 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
13.4k
Forks
1.2k
Avg merge
4d 45m
Merged PRs (30d)
13

Description

### 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;
^
```

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Inspect the macro and declaration in include/mimalloc-override.h and include/mimalloc.h, then compare them with Clang's mm_malloc.h declaration under the reported macOS and C++17 flags. Reproduce the compile error with -fno-exceptions; done means the declarations no longer conflict and the affected configurations compile successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, cpp
Domain
operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
54/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.