On 25/10/19 14:34 +0100, Jonathan Wakely wrote:
On 23/10/19 08:08 +0100, Jonathan Wakely wrote:
On Wed, 23 Oct 2019 at 00:33, Tam S. B. <cpplear...@outlook.com> wrote:
The use of concepts is causing `#include <functional>` to break on clang.

OK, thanks, I'll guard it with #if.

Fixed on trunk with this patch. My Clang 7.0.1 still can't compile current
trunk though, because we now have a constexpr destructor on
std::allocator.

Which should be fixed by this, which I'll commit after testing
finishes.

commit 063495404380ebe3d28429c6ce718cd05c8d5451
Author: Jonathan Wakely <jwak...@redhat.com>
Date:   Fri Oct 25 14:43:23 2019 +0100

    Fix compilation with Clang
    
    The new constexpr destructor on std::allocator breaks compilation with
    Clang in C++2a mode. This only makes it constexpr if the compiler
    supports the P0784R7 features.
    
            * include/bits/allocator.h: Check __cpp_constexpr_dynamic_alloc
            before making the std::allocator destructor constexpr.
            * testsuite/20_util/allocator/requirements/constexpr.cc: New test.

diff --git a/libstdc++-v3/include/bits/allocator.h b/libstdc++-v3/include/bits/allocator.h
index 2559c57b12e..00d7461e42e 100644
--- a/libstdc++-v3/include/bits/allocator.h
+++ b/libstdc++-v3/include/bits/allocator.h
@@ -160,7 +160,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	_GLIBCXX20_CONSTEXPR
 	allocator(const allocator<_Tp1>&) _GLIBCXX_NOTHROW { }
 
-      _GLIBCXX20_CONSTEXPR
+#if __cpp_constexpr_dynamic_alloc
+      constexpr
+#endif
       ~allocator() _GLIBCXX_NOTHROW { }
 
 #if __cplusplus > 201703L
diff --git a/libstdc++-v3/testsuite/20_util/allocator/requirements/constexpr.cc b/libstdc++-v3/testsuite/20_util/allocator/requirements/constexpr.cc
new file mode 100644
index 00000000000..6a6dbf1833f
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/allocator/requirements/constexpr.cc
@@ -0,0 +1,28 @@
+// Copyright (C) 2019 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++2a" }
+// { dg-do compile { target c++2a } }
+
+#include <memory>
+
+constexpr bool f()
+{
+  std::allocator<int> a;
+  return std::allocator_traits<std::allocator<int>>::max_size(a) > 0;
+}
+static_assert( f() );

Reply via email to