From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1984) id 3873139960EF; Fri, 17 Jul 2020 13:01:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3873139960EF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1594990874; bh=+ZAmk/EmNqlPUYvsz1yLvAE2X4cbiZa/yCw34lRZJ2U=; h=From:To:Subject:Date:From; b=TyVWuW7Lon3JsJ3A7D9P3IRW8bfic+qdkdaTkIZlqavk00qIOBnRP+vN+/wYIfvke R3OXNdCvNQb6g0JrIO/GRu0lmBb90OUfILXTPMiFlv3fIUeCsl4Pk/4tOBA0huv1dm otb6nWGQYYwqk7LHC0DhCWxraqSKbgsviMZkVtIY= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Tamar Christina To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc(refs/vendors/ARM/heads/arm-struct-reorg-wip)] libstdc++: midpoint should not constrain T is complete (LWG 3200) X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/vendors/ARM/heads/arm-struct-reorg-wip X-Git-Oldrev: 66ae31eb308e5bc90ce6dfd0a67381a0929a6aa0 X-Git-Newrev: 5f031f9747fdfb04213c20d24f109fb5ffc877df Message-Id: <20200717130114.3873139960EF@sourceware.org> Date: Fri, 17 Jul 2020 13:01:14 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Jul 2020 13:01:14 -0000 https://gcc.gnu.org/g:5f031f9747fdfb04213c20d24f109fb5ffc877df commit 5f031f9747fdfb04213c20d24f109fb5ffc877df Author: Jonathan Wakely Date: Wed Feb 19 15:01:41 2020 +0000 libstdc++: midpoint should not constrain T is complete (LWG 3200) * include/std/numeric (midpoint(T8, T*)): Do not check for complete type during overload resolution, use static assert instead (LWG 3200). * testsuite/26_numerics/midpoint/pointer.cc: Do not test with incomplete type. * testsuite/26_numerics/midpoint/pointer_neg.cc: New test. Diff: --- libstdc++-v3/ChangeLog | 6 +++++ libstdc++-v3/include/std/numeric | 4 ++-- .../testsuite/26_numerics/midpoint/pointer.cc | 2 -- .../testsuite/26_numerics/midpoint/pointer_neg.cc | 27 ++++++++++++++++++++++ 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 18085f3d9bd..84e5ea98022 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,11 @@ 2020-02-19 Jonathan Wakely + * include/std/numeric (midpoint(T8, T*)): Do not check for complete + type during overload resolution, use static assert instead (LWG 3200). + * testsuite/26_numerics/midpoint/pointer.cc: Do not test with + incomplete type. + * testsuite/26_numerics/midpoint/pointer_neg.cc: New test. + * include/std/span (span(T (&)[N])): Use non-deduced context to prevent first parameter from interfering with class template argument deduction (LWG 3369). diff --git a/libstdc++-v3/include/std/numeric b/libstdc++-v3/include/std/numeric index 0b0a8ff8a61..cf35191cb47 100644 --- a/libstdc++-v3/include/std/numeric +++ b/libstdc++-v3/include/std/numeric @@ -208,10 +208,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } template - constexpr - enable_if_t<__and_v, bool_constant>, _Tp*> + constexpr enable_if_t, _Tp*> midpoint(_Tp* __a, _Tp* __b) noexcept { + static_assert( sizeof(_Tp) != 0, "type must be complete" ); return __a + (__b - __a) / 2; } _GLIBCXX_END_NAMESPACE_VERSION diff --git a/libstdc++-v3/testsuite/26_numerics/midpoint/pointer.cc b/libstdc++-v3/testsuite/26_numerics/midpoint/pointer.cc index e0b75c92739..7e75d50663c 100644 --- a/libstdc++-v3/testsuite/26_numerics/midpoint/pointer.cc +++ b/libstdc++-v3/testsuite/26_numerics/midpoint/pointer.cc @@ -19,7 +19,6 @@ // { dg-do run { target c++2a } } #include -#include #include const int* p = nullptr; @@ -36,7 +35,6 @@ template constexpr bool no_midpoint() static_assert(no_midpoint()); static_assert(no_midpoint()); static_assert(no_midpoint()); -static_assert(no_midpoint()); constexpr int ca[3] = {}; static_assert( std::midpoint(ca, ca+3) == ca+1 ); diff --git a/libstdc++-v3/testsuite/26_numerics/midpoint/pointer_neg.cc b/libstdc++-v3/testsuite/26_numerics/midpoint/pointer_neg.cc new file mode 100644 index 00000000000..564b1acfe27 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/midpoint/pointer_neg.cc @@ -0,0 +1,27 @@ +// Copyright (C) 2020 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 +// . + +// { dg-options "-std=gnu++2a" } +// { dg-do compile { target c++2a } } + +#include + +// LWG 3200. midpoint should not constrain T is complete +struct Incomplete* pinc = 0; +auto p1 = std::midpoint(pinc, pinc); // { dg-error "here" } + +// { dg-error "incomplete type" "" { target *-*-* } 0 }