From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1888) id AD880386F81D; Mon, 28 Sep 2020 16:05:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AD880386F81D Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Patrick Palka To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r11-3501] libstdc++: Reduce the size of an unbounded iota_view X-Act-Checkin: gcc X-Git-Author: Patrick Palka X-Git-Refname: refs/heads/master X-Git-Oldrev: e189d5c931c5d94fd7487a2d1df9454d0b124eeb X-Git-Newrev: 623443357e6092067b4cf98cc6c0aeff7560b98d Message-Id: <20200928160553.AD880386F81D@sourceware.org> Date: Mon, 28 Sep 2020 16:05:53 +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: Mon, 28 Sep 2020 16:05:53 -0000 https://gcc.gnu.org/g:623443357e6092067b4cf98cc6c0aeff7560b98d commit r11-3501-g623443357e6092067b4cf98cc6c0aeff7560b98d Author: Patrick Palka Date: Mon Sep 28 11:54:57 2020 -0400 libstdc++: Reduce the size of an unbounded iota_view libstdc++-v3/ChangeLog: * include/std/ranges (iota_view::_M_bound): Give it [[no_unique_address]]. * testsuite/std/ranges/iota/iota_view.cc: Check that an unbounded iota_view has minimal size. Diff: --- libstdc++-v3/include/std/ranges | 2 +- libstdc++-v3/testsuite/std/ranges/iota/iota_view.cc | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges index ed04fa0001d..964a2b616a6 100644 --- a/libstdc++-v3/include/std/ranges +++ b/libstdc++-v3/include/std/ranges @@ -511,7 +511,7 @@ namespace ranges }; _Winc _M_value = _Winc(); - _Bound _M_bound = _Bound(); + [[no_unique_address]] _Bound _M_bound = _Bound(); public: iota_view() = default; diff --git a/libstdc++-v3/testsuite/std/ranges/iota/iota_view.cc b/libstdc++-v3/testsuite/std/ranges/iota/iota_view.cc index 65d166fbd3b..8a33e10a093 100644 --- a/libstdc++-v3/testsuite/std/ranges/iota/iota_view.cc +++ b/libstdc++-v3/testsuite/std/ranges/iota/iota_view.cc @@ -77,6 +77,9 @@ test04() VERIFY( it == v.end() ); } +// Verify we optimize away the 'bound' data member of an unbounded iota_view. +static_assert(sizeof(std::ranges::iota_view) == 1); + int main() {