diff --git a/cmake/modules/CheckCXXFeatures.cmake b/cmake/modules/CheckCXXFeatures.cmake
index 707d14d83312acf5419eee77c283ec4689e7d7b7..67b7bf4bef9b1d360751467c6fcf557c79ab733d 100644
--- a/cmake/modules/CheckCXXFeatures.cmake
+++ b/cmake/modules/CheckCXXFeatures.cmake
@@ -484,6 +484,17 @@ check_cxx_source_compiles("
 " DUNE_SUPPORTS_CXX_THROW_IN_CONSTEXPR
   )
 
+# Check whether the stadard library supports aligned_alloc()
+check_cxx_source_compiles("
+  #include <cstdlib>
+  int main()
+  {
+    int* p = static_cast<int*>(aligned_alloc(64, 64*sizeof *p));
+  }
+" DUNE_HAVE_C_ALIGNED_ALLOC
+  )
+
+
 
 # ******************************************************************************
 #
diff --git a/config.h.cmake b/config.h.cmake
index e06c65b735c90eeb0719e47a2892091d60061f91..f0dd6722a384d62121a2a3efec51e1164fb1bab0 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -35,6 +35,9 @@
 /* does the compiler support conditionally throwing exceptions in constexpr context? */
 #cmakedefine DUNE_SUPPORTS_CXX_THROW_IN_CONSTEXPR 1
 
+/* does the standard library provides aligned_alloc()? */
+#cmakedefine DUNE_HAVE_C_ALIGNED_ALLOC 1
+
 /* does the standard library provide <experimental/type_traits> ? */
 #cmakedefine DUNE_HAVE_HEADER_EXPERIMENTAL_TYPE_TRAITS 1
 
diff --git a/dune/common/alignedallocator.hh b/dune/common/alignedallocator.hh
index cef4d6680afdf78541bedc432608840fd16b9212..ac9e20302b4466a29ee90ff7e0861abcd8b67859 100644
--- a/dune/common/alignedallocator.hh
+++ b/dune/common/alignedallocator.hh
@@ -6,6 +6,10 @@
 #include "mallocallocator.hh"
 #include <cstdlib>
 
+#if !(DUNE_HAVE_C_ALIGNED_ALLOC || (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600))
+  #error Need either aligned_alloc() or posix_memalign() to compile AlignedAllocator
+#endif
+
 namespace Dune
 {
 
@@ -19,7 +23,7 @@ namespace Dune
   template<class T, int Alignment = -1>
   class AlignedAllocator : public MallocAllocator<T> {
 
-#if __APPLE__
+#if !DUNE_HAVE_C_ALIGNED_ALLOC
 
     /*
      * posix_memalign() on macOS has pretty draconian restrictions on the
@@ -67,7 +71,7 @@ namespace Dune
       if (n > this->max_size())
         throw std::bad_alloc();
 
-#if __APPLE__
+#if !DUNE_HAVE_C_ALIGNED_ALLOC
       /*
        * Apple's standard library doesn't have aligned_alloc() - C11 is still something
        * from the future in Cupertino. Luckily, they got around to finally implementing