Go to file
Jonathan Wakely a942dfca6a PR libstdc++/87520 Always pass type-punned type_info reference
The implementations of std::make_shared for -frtti and -fno-rtti are not
compatible, because they pass different arguments to
_Sp_counted_ptr_inplace::_M_get_deleter and so can't interoperate.
Either the argument doesn't match the expected value, and so the
shared_ptr::_M_ptr member is never set, or the type-punned reference is
treated as a real std::type_info object and gets dereferenced.

This patch removes the differences between -frtti and -fno-rtti, so that
typeid is never used, and the type-punned reference is used in both
cases. For backwards compatibility with existing code that passes
typeid(_Sp_make_shared_tag) that still needs to be handled, but only
after checking that the argument is not the type-punned reference (so
it's safe to treat as a real std::type_info object). The reference is
bound to an object of literal type, so that it doesn't need a guard
variable to make its initialization thread-safe.

This patch also fixes 87520 by ensuring that the type-punned reference
is bound to "a region of storage of suitable size and alignment to
contain an object of the reference's type" (as per the proposed
resolution of Core DR 453).

If all objects are built with the fixed version of GCC then -frtti and
-fno-rtti can be mixed freely and std::make_shared will work correctly.
If some objects are built with unfixed GCC versions then problems can
still arise, depending on which template instantiations are kept by the
linker.

	PR libstdc++/85930
	PR libstdc++/87520
	* include/bits/shared_ptr_base.h (_Sp_make_shared_tag::_S_ti)
	[__cpp_rtti]: Define even when RTTI is enabled. Use array of
	sizeof(type_info) so that type-punned reference binds to an object
	of the correct size as well as correct alignment.
	(_Sp_counted_ptr_inplace::_M_get_deleter) [__cpp_rtti]: Check for
	_S_ti() reference even when RTTI is enabled.
	(__shared_ptr(_Sp_make_shared_tag, const _Alloc&, _Args&&...))
	[__cpp_rtti]: Pass _S_ti() instead of typeid(_Sp_make_shared_tag).

From-SVN: r266376
2018-11-22 13:42:39 +00:00
INSTALL
config
contrib Detect mixed usage of spaces and tabs. 2018-11-19 08:08:28 +00:00
fixincludes
gcc Update changelog entry. 2018-11-22 10:44:40 +00:00
gnattools PR81878: fix --disable-bootstrap --enable-languages=ada 2018-11-20 00:07:47 +00:00
gotools
include
intl
libada
libatomic
libbacktrace [libbacktrace] Factor out read_initial_length 2018-11-22 00:06:27 +00:00
libcc1 Eliminate source_location in favor of location_t 2018-11-13 20:05:03 +00:00
libcpp Eliminate source_location in favor of location_t 2018-11-13 20:05:03 +00:00
libdecnumber
libffi
libgcc linux-unwind.h (sc_pt_regs): Update for kernel. 2018-11-16 01:26:04 +00:00
libgfortran Replace sync builtins with atomic builtins 2018-11-22 09:58:29 +02:00
libgo re PR go/88060 (../../../gcc-8.2.0/libgo/go/syscall/libcall_linux_utimesnano.go:17:18: error: reference to undefined name ‘_AT_FDCWD’) 2018-11-21 02:16:15 +00:00
libgomp re PR bootstrap/88106 (Bootstrap failure on mingw32) 2018-11-20 11:39:53 +01:00
libhsail-rt
libiberty
libitm
libobjc
liboffloadmic
libphobos re PR d/87824 (x86_64-linux multilib issues) 2018-11-22 06:14:47 +00:00
libquadmath
libsanitizer
libssp
libstdc++-v3 PR libstdc++/87520 Always pass type-punned type_info reference 2018-11-22 13:42:39 +00:00
libvtv
lto-plugin
maintainer-scripts
zlib
.dir-locals.el
.gitattributes
.gitignore
ABOUT-NLS
COPYING
COPYING.LIB
COPYING.RUNTIME
COPYING3
COPYING3.LIB
ChangeLog Move a test-case to a proper folder. 2018-11-13 15:28:26 +00:00
ChangeLog.jit
ChangeLog.tree-ssa
MAINTAINERS
Makefile.def
Makefile.in
Makefile.tpl
README
ar-lib
compile
config-ml.in
config.guess
config.rpath
config.sub
configure
configure.ac
depcomp
install-sh
libtool-ldflags
libtool.m4
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
lt~obsolete.m4
missing
mkdep
mkinstalldirs
move-if-change
multilib.am
symlink-tree
test-driver
ylwrap

README

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.