]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/27_io/filesystem/path/concat/92853.cc
libstdc++: Remove redundant -std=gnu++17 options from filesystem tests
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 27_io / filesystem / path / concat / 92853.cc
1 // Copyright (C) 2019-2021 Free Software Foundation, Inc.
2 //
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
7 // any later version.
8
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
17
18 // { dg-do run { target c++17 } }
19
20 #include <filesystem>
21 #include <testsuite_fs.h>
22
23 void
24 test01()
25 {
26 // PR libstdc++/92853
27 using std::filesystem::path;
28 path p1{ "." }, p2{ "/" };
29 p1 += p2; // corrupts heap
30 path p3{ p1 }; // CRASH!
31 __gnu_test::compare_paths( p3, "./" );
32 }
33
34 void
35 test02()
36 {
37 using std::filesystem::path;
38 path p1{ "." }, p2{ "////" };
39 p1 += p2;
40 path p3{ p1 };
41 __gnu_test::compare_paths( p3, ".////" );
42 }
43
44 void
45 test03()
46 {
47 using std::filesystem::path;
48 path p1{ "./" }, p2{ "/" };
49 p1 += p2;
50 path p3{ p1 };
51 __gnu_test::compare_paths( p3, ".//" );
52 }
53
54 int
55 main()
56 {
57 test01();
58 test02();
59 test03();
60 }