PR libstdc++/83860 avoid dangling references in valarray closure types
authorJonathan Wakely <jwakely@redhat.com>
Wed, 2 May 2018 16:41:46 +0000 (17:41 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Wed, 2 May 2018 16:41:46 +0000 (17:41 +0100)
commit1b749ae95e7ec7709ebb57ddbfceb752519c4277
treebc2c411d73c7fd287e111fff052dbb75e7723208
parent59bcf90013d286b73e886ef403c4db9d12862ee2
PR libstdc++/83860 avoid dangling references in valarray closure types

Store nested closures by value not by reference, to prevent holding
invalid references to temporaries that have been destroyed. This
changes the layout of the closure types, so change their linkage names,
but moving them to a different namespace.

PR libstdc++/57997
PR libstdc++/83860
* include/bits/gslice_array.h (gslice_array): Define default
constructor as deleted, as per C++11 standard.
* include/bits/mask_array.h (mask_array): Likewise.
* include/bits/slice_array.h (slice_array): Likewise.
* include/bits/valarray_after.h (_GBase, _GClos, _IBase, _IClos): Move
to namespace __detail.
(_GBase::_M_expr, _IBase::_M_expr): Use _ValArrayRef for type of data
members.
* include/bits/valarray_before.h (_ValArrayRef): New helper for type
of data members in closure objects.
(_FunBase, _ValFunClos, _RefFunClos, _UnBase, _UnClos, _BinBase)
(_BinBase2, _BinBase1, _BinClos, _SBase, _SClos): Move to namespace
__detail.
(_FunBase::_M_expr, _UnBase::_M_expr, _BinBase::_M_expr1)
(_BinBase::_M_expr2, _BinBase2::_M_expr1, _BinBase1::_M_expr2)
(_SBase::_M_expr): Use _ValArrayRef for type of data members.
* include/std/valarray (_UnClos, _BinClos, _SClos, _GClos, _IClos)
(_ValFunClos, _RefFunClos): Move to namespace __detail and add
using-declarations to namespace std.
* testsuite/26_numerics/valarray/83860.cc: New.

From-SVN: r259844
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/gslice_array.h
libstdc++-v3/include/bits/mask_array.h
libstdc++-v3/include/bits/slice_array.h
libstdc++-v3/include/bits/valarray_after.h
libstdc++-v3/include/bits/valarray_before.h
libstdc++-v3/include/std/valarray
libstdc++-v3/testsuite/26_numerics/valarray/83860.cc [new file with mode: 0644]