gcc/libstdc++-v3
Jonathan Wakely ea182fe636 libstdc++: Handle type-changing path concatenations (PR 94063)
The filesystem::path::operator+= and filesystem::path::concat functions
operate directly on the native format of the path and so can cause a
path to mutate to a completely different type.

For Windows combining a filename "x" with a filename ":" produces a
root-name "x:". Similarly, a Cygwin root-directory "/" combined with a
root-directory and filename "/x" produces a root-name "//x".

Before this patch the implemenation didn't support those kind of
mutations, assuming that concatenating two filenames would always
produce a filename and concatenating with a root-dir would still have a
root-dir.

This patch fixes it simply by checking for the problem cases and
creating a new path by re-parsing the result of the string
concatenation. This is slightly suboptimal because the argument has
already been parsed if it's a path, but more importantly it doesn't
reuse any excess capacity that the path object being modified might
already have allocated. That can be fixed later though.

	PR libstdc++/94063
	* src/c++17/fs_path.cc (path::operator+=(const path&)): Add kluge to
	handle concatenations that change the type of the first component.
	(path::operator+=(basic_string_view<value_type>)): Likewise.
	* testsuite/27_io/filesystem/path/concat/94063.cc: New test.
2020-03-09 23:22:57 +00:00
..
config x32: Update baseline_symbols.txt 2020-03-01 06:13:28 -08:00
doc Add `--with-toolexeclibdir=' configuration option 2020-01-24 11:24:25 +00:00
include libstdc++: Add missing friend declaration to join_view::_Sentinel 2020-03-06 09:23:10 -05:00
libsupc++ libstdc++: Remove std::type_info::operator!= for C++20 2020-02-20 11:30:19 +00:00
po Add `--with-toolexeclibdir=' configuration option 2020-01-24 11:24:25 +00:00
python libstdc++: Fix regression in libstdc++-prettyprinters/cxx20.cc 2020-02-17 13:20:57 +00:00
scripts
src libstdc++: Handle type-changing path concatenations (PR 94063) 2020-03-09 23:22:57 +00:00
testsuite libstdc++: Handle type-changing path concatenations (PR 94063) 2020-03-09 23:22:57 +00:00
acinclude.m4 libstdc++: Replace glibc-specific check for clock_gettime (PR 93325) 2020-01-28 13:24:09 +00:00
aclocal.m4 Add `--with-toolexeclibdir=' configuration option 2020-01-24 11:24:25 +00:00
ChangeLog libstdc++: Handle type-changing path concatenations (PR 94063) 2020-03-09 23:22:57 +00:00
ChangeLog-1998
ChangeLog-1999
ChangeLog-2000
ChangeLog-2001
ChangeLog-2002
ChangeLog-2003
ChangeLog-2004
ChangeLog-2005
ChangeLog-2006
ChangeLog-2007
ChangeLog-2008
ChangeLog-2009
ChangeLog-2010
ChangeLog-2011
ChangeLog-2012
ChangeLog-2013
ChangeLog-2014
ChangeLog-2015
ChangeLog-2016
ChangeLog-2017
ChangeLog-2018
ChangeLog-2019
config.h.in
configure Use a non-empty test program to test ability to link. 2020-02-12 13:22:07 -08:00
configure.ac
configure.host
crossconfig.m4 reject macros in math decl check 2020-01-23 16:44:54 -03:00
fragment.am
linkage.m4
Makefile.am
Makefile.in Add `--with-toolexeclibdir=' configuration option 2020-01-24 11:24:25 +00:00
README

file: libstdc++-v3/README

New users may wish to point their web browsers to the file
index.html in the 'doc/html' subdirectory.  It contains brief
building instructions and notes on how to configure the library in
interesting ways.