From 6572dbc2fa36fb9189bd1ed21748e73a88418e15 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Fri, 6 Dec 2019 16:36:01 +0100 Subject: Adapt o3tl::span to P1872R0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ..."span should have size_type, not index_type" (), as implemented by libc++ since "[libc++][P1872] span should have size_type, not index_type." All uses of index_type had been added to mitigate the previous std::span change from signed (ptrdiff_t) to unsigned (size_t) index_type, see 6ef8420fdbf8dff16de13147c5ab833bc5e01121 "Adapt o3tl::span to updated C++2a std::span". There is no easy solution to transparently support all three std::span variants currently out there (signed index_type, unsigned index_type, unsigned size_type), without causing compilation failures due to CPPUNIT_ASSERT_EQUAL with arguments of different types, or compiler warnings about mixed signed/unsigned comparisons. So rule out the oldest std::span variant (signed index_type) in configure.ac (so that o3tl::span will use its own hand-rolled code in that case) and simplify the uses of index_type to std::size_t (as had already been mentioned in 6ef8420fdbf8dff16de13147c5ab833bc5e01121). Reviewed-on: https://gerrit.libreoffice.org/84652 Tested-by: Jenkins Reviewed-by: Stephan Bergmann (cherry picked from commit 8e6865188242bccb3d8aa857ddc990d72a058d3d) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87757 Reviewed-by: Caolán McNamara (cherry picked from commit bb9833594b031c6d0ec91422f85968c4b1f2f8bc) Change-Id: I6ddf424ffb7941da3f69ad66fd29ecd35f09afae --- configure.ac | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index 2b33e5f0bc0a..0e61b295b66f 100644 --- a/configure.ac +++ b/configure.ac @@ -6766,6 +6766,22 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([ CXXFLAGS=$save_CXXFLAGS AC_LANG_POP([C++]) +AC_MSG_CHECKING([whether $CXX supports C++2a with unsigned size_type]) +AC_LANG_PUSH([C++]) +save_CXXFLAGS=$CXXFLAGS +CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11" +AC_COMPILE_IFELSE([AC_LANG_SOURCE([ + #include + #include + // Don't check size_type directly, as it was called index_type before P1872R0: + void f(std::span s) { static_assert(std::is_unsigned_v); }; + ])], [ + AC_DEFINE([HAVE_CPP_SPAN],[1]) + AC_MSG_RESULT([yes]) + ], [AC_MSG_RESULT([no])]) +CXXFLAGS=$save_CXXFLAGS +AC_LANG_POP([C++]) + AC_MSG_CHECKING([whether $CXX has GCC bug 87150]) AC_LANG_PUSH([C++]) save_CXXFLAGS=$CXXFLAGS -- cgit