From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 64752 invoked by alias); 1 Dec 2017 16:10:27 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 64685 invoked by uid 89); 1 Dec 2017 16:10:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.7 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KB_WAM_FROM_NAME_SINGLEWORD,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 01 Dec 2017 16:10:25 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DA4AF686BE; Fri, 1 Dec 2017 16:10:23 +0000 (UTC) Received: from localhost (unknown [10.33.36.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id 73FE55D960; Fri, 1 Dec 2017 16:10:23 +0000 (UTC) Date: Fri, 01 Dec 2017 16:10:00 -0000 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Fix -Wsystem-header warnings in libstdc++ Message-ID: <20171201161022.GY31922@redhat.com> References: <20171201151156.GW31922@redhat.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="QWRRbczYj8mXuejp" Content-Disposition: inline In-Reply-To: <20171201151156.GW31922@redhat.com> X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.9.1 (2017-09-22) X-SW-Source: 2017-12/txt/msg00054.txt.bz2 --QWRRbczYj8mXuejp Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline Content-length: 188 On 01/12/17 15:11 +0000, Jonathan Wakely wrote: >This fixes a number of warnings that show up with -Wsystem-headers This fixes some more. Tested powerpc64le-linux, committed to trunk. --QWRRbczYj8mXuejp Content-Type: text/x-patch; charset=us-ascii Content-Disposition: attachment; filename="patch.txt" Content-length: 7520 commit cea830828177721a6d201dd6c201c34235626641 Author: Jonathan Wakely Date: Fri Dec 1 15:59:01 2017 +0000 Fix narrowing conversions in string_view types * include/experimental/string_view (basic_string_view::_S_compare): Use value-init so narrowing conversions are not ill-formed. * include/std/string_view (basic_string_view::_S_compare): Likewise. diff --git a/libstdc++-v3/include/experimental/string_view b/libstdc++-v3/include/experimental/string_view index 96d1f58f8e9..ef171ecc025 100644 --- a/libstdc++-v3/include/experimental/string_view +++ b/libstdc++-v3/include/experimental/string_view @@ -422,11 +422,11 @@ inline namespace fundamentals_v1 static constexpr int _S_compare(size_type __n1, size_type __n2) noexcept { - return difference_type{__n1 - __n2} > std::numeric_limits::max() + return difference_type(__n1 - __n2) > std::numeric_limits::max() ? std::numeric_limits::max() - : difference_type{__n1 - __n2} < std::numeric_limits::min() + : difference_type(__n1 - __n2) < std::numeric_limits::min() ? std::numeric_limits::min() - : static_cast(difference_type{__n1 - __n2}); + : static_cast(difference_type(__n1 - __n2)); } size_t _M_len; diff --git a/libstdc++-v3/include/std/string_view b/libstdc++-v3/include/std/string_view index 1266a07d04f..3b2901ab3c6 100644 --- a/libstdc++-v3/include/std/string_view +++ b/libstdc++-v3/include/std/string_view @@ -408,7 +408,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION static constexpr int _S_compare(size_type __n1, size_type __n2) noexcept { - const difference_type __diff{__n1 - __n2}; + const difference_type __diff = __n1 - __n2; if (__diff > std::numeric_limits::max()) return std::numeric_limits::max(); if (__diff < std::numeric_limits::min()) commit b992ef59e17964034ffb6dd094629468998ee6e9 Author: Jonathan Wakely Date: Thu Nov 30 16:26:22 2017 +0000 Disable -Wliteral-suffix for standard UDLs * include/bits/basic_string.h (operator""s): Add pragmas to disable -Wliteral-suffix warnings. * include/experimental/string_view (operator""sv): Likewise. * include/std/chrono (operator""h, operator""min, operator""s) (operator""ms, operator""us, operator""ns): Likewise. * include/std/complex (operator""if, operator""i, operator""il): Likewise. * include/std/string_view (operator""sv): Likewise. * testsuite/20_util/duration/literals/range.cc: Adjust dg-error. diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h index a4b81137571..70373e7448a 100644 --- a/libstdc++-v3/include/bits/basic_string.h +++ b/libstdc++-v3/include/bits/basic_string.h @@ -6665,6 +6665,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { inline namespace string_literals { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wliteral-suffix" _GLIBCXX_DEFAULT_ABI_TAG inline basic_string operator""s(const char* __str, size_t __len) @@ -6689,6 +6691,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return basic_string{__str, __len}; } #endif +#pragma GCC diagnostic pop } // inline namespace string_literals } // inline namespace literals diff --git a/libstdc++-v3/include/experimental/string_view b/libstdc++-v3/include/experimental/string_view index 8eaf9ec3d96..96d1f58f8e9 100644 --- a/libstdc++-v3/include/experimental/string_view +++ b/libstdc++-v3/include/experimental/string_view @@ -644,6 +644,8 @@ namespace experimental { inline namespace string_view_literals { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wliteral-suffix" inline constexpr basic_string_view operator""sv(const char* __str, size_t __len) noexcept { return basic_string_view{__str, __len}; } @@ -663,6 +665,7 @@ namespace experimental operator""sv(const char32_t* __str, size_t __len) noexcept { return basic_string_view{__str, __len}; } #endif +#pragma GCC diagnostic pop } // namespace string_literals } // namespace literals } // namespace experimental diff --git a/libstdc++-v3/include/std/chrono b/libstdc++-v3/include/std/chrono index 9491508e637..2419e82acce 100644 --- a/libstdc++-v3/include/std/chrono +++ b/libstdc++-v3/include/std/chrono @@ -884,6 +884,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { inline namespace chrono_literals { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wliteral-suffix" template struct _Checked_integral_constant : integral_constant<_Rep, static_cast<_Rep>(_Val)> @@ -958,6 +960,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION operator""ns() { return __check_overflow(); } +#pragma GCC diagnostic pop } // inline namespace chrono_literals } // inline namespace literals @@ -966,7 +969,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION using namespace literals::chrono_literals; } // namespace chrono -#endif // __cplusplus > 201103L +#endif // C++14 // @} group chrono diff --git a/libstdc++-v3/include/std/complex b/libstdc++-v3/include/std/complex index bd8b09d84f0..61f8cc1fce3 100644 --- a/libstdc++-v3/include/std/complex +++ b/libstdc++-v3/include/std/complex @@ -1941,6 +1941,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION inline namespace literals { inline namespace complex_literals { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wliteral-suffix" #define __cpp_lib_complex_udls 201309 constexpr std::complex @@ -1967,6 +1969,7 @@ inline namespace complex_literals { operator""il(unsigned long long __num) { return std::complex{0.0L, static_cast(__num)}; } +#pragma GCC diagnostic pop } // inline namespace complex_literals } // inline namespace literals diff --git a/libstdc++-v3/include/std/string_view b/libstdc++-v3/include/std/string_view index 68b4b08f8f4..1266a07d04f 100644 --- a/libstdc++-v3/include/std/string_view +++ b/libstdc++-v3/include/std/string_view @@ -626,6 +626,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { inline namespace string_view_literals { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wliteral-suffix" inline constexpr basic_string_view operator""sv(const char* __str, size_t __len) noexcept { return basic_string_view{__str, __len}; } @@ -645,6 +647,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION operator""sv(const char32_t* __str, size_t __len) noexcept { return basic_string_view{__str, __len}; } #endif +#pragma GCC diagnostic pop } // namespace string_literals } // namespace literals diff --git a/libstdc++-v3/testsuite/20_util/duration/literals/range.cc b/libstdc++-v3/testsuite/20_util/duration/literals/range.cc index c0d1a6e5885..20d82c5cdbe 100644 --- a/libstdc++-v3/testsuite/20_util/duration/literals/range.cc +++ b/libstdc++-v3/testsuite/20_util/duration/literals/range.cc @@ -26,6 +26,6 @@ test01() // std::numeric_limits::max() == 9223372036854775807; auto h = 9223372036854775808h; - // { dg-error "cannot be represented" "" { target *-*-* } 892 } + // { dg-error "cannot be represented" "" { target *-*-* } 894 } } // { dg-prune-output "in constexpr expansion" } // needed for -O0 --QWRRbczYj8mXuejp--