From: Patrick Palka Date: Mon, 28 Sep 2020 15:54:57 +0000 (-0400) Subject: libstdc++: Reduce the size of an unbounded iota_view X-Git-Tag: upstream/12.2.0~13453 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=623443357e6092067b4cf98cc6c0aeff7560b98d;p=platform%2Fupstream%2Fgcc.git 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 --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges index ed04fa0..964a2b6 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 65d166f..8a33e10 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() {