Skip to content

Commit

Permalink
Merge pull request #865 from xtensor-stack/feature/support-no-except
Browse files Browse the repository at this point in the history
Make xsimd compatible with -fno-exceptions
  • Loading branch information
JohanMabille committed Nov 23, 2022
2 parents 68d5d3e + c057c2e commit 73c90a2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/cxx-no-exceptions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: C++ -fno-except compatibility
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: |
sudo apt install g++ cmake
- name: Setup
run: |
mkdir _build
cd _build && cmake .. -DBUILD_TESTS=ON -DDOWNLOAD_DOCTEST=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS=-fno-exceptions
- name: Build
run: cmake --build _build

2 changes: 2 additions & 0 deletions include/xsimd/memory/xsimd_aligned_allocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,10 @@ namespace xsimd
aligned_allocator<T, A>::allocate(size_type n, const void*) -> pointer
{
pointer res = reinterpret_cast<pointer>(aligned_malloc(sizeof(T) * n, A));
#if defined(_CPPUNWIND) || defined(__cpp_exceptions)
if (res == nullptr)
throw std::bad_alloc();
#endif
return res;
}

Expand Down

0 comments on commit 73c90a2

Please sign in to comment.