Go to file
Patrick Palka 6e63438a0d libstdc++: Fix capturing of lvalue references in_RangeAdaptor::operator()
This fixes a dangling-reference issue with views::split and other multi-argument
adaptors that may take its extra arguments by reference.

When creating the _RangeAdaptorClosure in _RangeAdaptor::operator(), we
currently capture all provided arguments by value.  When we then use the
_RangeAdaptorClosure and call it with a range, as in e.g.

    v = views::split(p)(range),

we forward the range and the captures to the underlying adaptor routine.  But
then when the temporary _RangeAdaptorClosure goes out of scope, the by-value
captures get destroyed and the references to these captures in the resulting view
become dangling.

This patch fixes this problem by capturing lvalue references by reference in
_RangeAdaptorClosure::operator(), and then forwarding the captures appropriately
to the underlying adaptor routine.

libstdc++-v3/ChangeLog:

	* include/std/ranges (views::__adaptor::__maybe_refwrap): New utility
	function.
	(views::__adaptor::_RangeAdaptor::operator()): Add comments.  Use
	__maybe_refwrap to capture lvalue references by reference, and then use
	unwrap_reference_t to forward the by-reference captures as references.
	* testsuite/std/ranges/adaptors/split.cc: Augment test.
	* testsuite/std/ranges/adaptors/split_neg.cc: New test.
2020-02-20 14:06:23 -05:00
config Use a non-empty test program to test ability to link. 2020-02-12 13:22:07 -08:00
contrib
fixincludes rs6000: fixinc: Skip machine_name fix for powerpc*-*-linux* 2020-02-14 00:00:33 +00:00
gcc rs6000: Fix infinite loop building ghostscript and icu [PR93658] 2020-02-20 11:25:12 -06:00
gnattools
gotools
include
INSTALL
intl
libada
libatomic
libbacktrace libbacktrace: update to current libgo test file 2020-02-15 18:25:13 -08:00
libcc1
libcpp Update cpplib sv.po. 2020-02-17 21:25:05 +00:00
libdecnumber
libffi
libgcc Introduce -fprofile-reproducibility and support it with TOP N. 2020-02-18 14:28:22 +01:00
libgfortran Use au->lock exclusively for locking in async I/O. 2020-02-18 19:45:25 +01:00
libgo cmd/go: update -DGOPKGPATH to use current pkgpath encoding 2020-02-18 12:03:13 -08:00
libgomp libgomp: Fixes + cleanup for OpenACC's Fortran module + openacc_lib.h 2020-02-19 09:13:44 +01:00
libhsail-rt
libiberty Use a non-empty test program to test ability to link. 2020-02-12 13:22:07 -08:00
libitm Use a non-empty test program to test ability to link. 2020-02-12 13:22:07 -08:00
libobjc Use a non-empty test program to test ability to link. 2020-02-12 13:22:07 -08:00
liboffloadmic
libphobos Fix a typo. 2020-02-17 13:20:06 +01:00
libquadmath Use a non-empty test program to test ability to link. 2020-02-12 13:22:07 -08:00
libsanitizer
libssp Use a non-empty test program to test ability to link. 2020-02-12 13:22:07 -08:00
libstdc++-v3 libstdc++: Fix capturing of lvalue references in_RangeAdaptor::operator() 2020-02-20 14:06:23 -05:00
libvtv
lto-plugin
maintainer-scripts
zlib
.dir-locals.el
.gitattributes
.gitignore
ABOUT-NLS
ar-lib
ChangeLog Document compatibility of aliases and their targets, correct weakref example. 2020-02-14 17:13:29 -07:00
ChangeLog.jit
ChangeLog.tree-ssa
compile
config-ml.in
config.guess
config.rpath
config.sub
configure
configure.ac
COPYING
COPYING3
COPYING3.LIB
COPYING.LIB
COPYING.RUNTIME
depcomp
install-sh
libtool-ldflags
libtool.m4
lt~obsolete.m4
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
MAINTAINERS
Makefile.def
Makefile.in
Makefile.tpl
missing
mkdep
mkinstalldirs
move-if-change
multilib.am
README
symlink-tree
test-driver
ylwrap

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.