aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
AgeCommit message (Collapse)AuthorFilesLines
3 hoursDaily bump.HEADtrunkmasterGCC Administrator1-0/+14
6 hourslibstdc++: Remove redundant reclaration of std::optionalJonathan Wakely1-3/+0
We've already declared optional at the top of the header, so don't need to do it again. libstdc++-v3/ChangeLog: * include/std/optional: Remove redundant redeclaration.
6 hourslibstdc++: Fix indentation of lines that follow a [[likely]] attributeJonathan Wakely1-2/+2
libstdc++-v3/ChangeLog: * include/std/text_encoding: Fix indentation.
6 hourslibstdc++: Adjust testcase for constexpr placement new [PR115744]Jonathan Wakely1-2/+7
This test now fails in C++26 mode because the declaration in <new> is constexpr and the one in the test isn't. Add constexpr to the test. libstdc++-v3/ChangeLog: PR libstdc++/115744 * testsuite/18_support/headers/new/synopsis.cc [C++26]: Add constexpr to placement operator new and operator new[].
2 daysDaily bump.GCC Administrator1-0/+6
2 dayslibstdc++: Remove note from the GCC 4.0.1 daysGerald Pfeifer2-8/+2
libstdc++-v3: * doc/xml/manual/prerequisites.xml: Remove note from the GCC 4.0.1 days. * doc/html/manual/setup.html: Regenerate.
3 daysDaily bump.GCC Administrator1-0/+24
4 dayslibstdc++: Update references to gcc.gnu.org/onlinedocsGerald Pfeifer13-17/+17
libstdc++-v3: * doc/xml/manual/abi.xml: Update reference to gcc.gnu.org/onlinedocs. * doc/xml/manual/concurrency_extensions.xml (interface): Ditto. * doc/xml/manual/extensions.xml: Ditto. * doc/xml/manual/parallel_mode.xml: Ditto. * doc/xml/manual/shared_ptr.xml: Ditto. * doc/xml/manual/using_exceptions.xml: Ditto. And change GNU GCC to GCC. * doc/html/manual/abi.html: Regenerate. * doc/html/manual/ext_concurrency_impl.html: Ditto. * doc/html/manual/ext_demangling.html: Ditto. * doc/html/manual/memory.html: Ditto. * doc/html/manual/parallel_mode_design.html: Ditto. * doc/html/manual/parallel_mode_using.html: Ditto. * doc/html/manual/using_exceptions.html: Ditto.
4 dayslibstdc++: Tweak links to installation docsGerald Pfeifer2-5/+6
libstdc++v-3: * doc/xml/manual/prerequisites.xml: Tweak two links to installation docs. Fix grammar. * doc/html/manual/setup.html: Regenerate.
4 daysDaily bump.GCC Administrator1-0/+11
5 dayslibstdc++-v3: Handle iconv as optional for newlib builds [PR116362]Hans-Peter Nilsson2-2/+34
Support for iconv in newlib seems to have been always assumed present by libstdc++-v3, but is default off. Though, it hasn't been used before recent libstdc++ changes that actually call iconv functions. This now leads to failures exposed by running the test-suite, unless the newlib being used has been explicitly configured with --enable-newlib-iconv. When failing, there are undefined references to iconv, iconv_open or iconv_close for multiple tests. Thankfully there's a macro in newlib.h that we can check to detect presence of iconv support for the newlib build that's used. libstdc++-v3: PR libstdc++/116362 * configure.ac: Check newlib configuration whether iconv is enabled. * configure: Regenerate.
5 dayslibstdc++-v3: testsuite: Prune uncapitalized "in function" linker warningHans-Peter Nilsson1-0/+9
Newer newlib trigger warnings about certain functions not implemented (_getentropy) when testing libstdc++-v3. Since 2018 (circa binutils-2.31) the "in function" prefix isn't capitalized for those "not implemented" warnings when generated from the linker (a GNU ld feature used by newlib). Dejagnu up to and including at least dejagnu-1.6.3 (and git @ 42979bd3b9) assumes a capital "In function", leaving that part unpruned, and boom we have thousands of "excess errors" from the libstdc++-v3 testsuite. While gcc/testsuite/lib/prune.exp:prune_gcc_output already deals with this quirk with a vastly more generic pattern, I choose this simpler tweak. libstdc++-v3: * testsuite/lib/prune.exp (libstdc++-dg-prune): Prune uncapitalized "in function" warning from linker.
12 daysDaily bump.GCC Administrator1-0/+11
13 daysc++, libstdc++: Implement C++26 P2747R2 - constexpr placement new [PR115744]Jakub Jelinek3-2/+32
With the PR115754 fix in, constexpr placement new mostly just works, so this patch just adds constexpr keyword to the placement new operators in <new>, adds FTMs and testsuite coverage. There is one accepts-invalid though, the new (p + 1) int[]{2, 3}; // error (in this paper) case from the paper. Can we handle that incrementally? The problem with that is I think calling operator new now that it is constexpr should be fine even in that case in constant expressions, so int *p = std::allocator<int>{}.allocate(3); int *q = operator new[] (sizeof (int) * 2, p + 1); should be ok, so it can't be easily the placement new operator call itself on whose constexpr evaluation we try something special, it should be on the new expression, but constexpr.cc actually sees only <<< Unknown tree: expr_stmt (void) (TARGET_EXPR <D.2640, (void *) TARGET_EXPR <D.2641, VIEW_CONVERT_EXPR<int *>(b) + 4>>, TARGET_EXPR <D.2642, operator new [] (8, NON_LVALUE_EXPR <D.2640>)>, int * D.2643; <<< Unknown tree: expr_stmt (void) (D.2643 = (int *) D.2642) >>>; and that is just fine by the preexisting constexpr evaluation rules. Should build_new_1 emit some extra cast for the array cases with placement new in maybe_constexpr_fn (current_function_decl) that the existing P2738 code would catch? 2024-08-08 Jakub Jelinek <jakub@redhat.com> PR c++/115744 gcc/c-family/ * c-cppbuiltin.cc (c_cpp_builtins): Change __cpp_constexpr from 202306L to 202406L for C++26. gcc/testsuite/ * g++.dg/cpp2a/construct_at.h (operator new, operator new[]): Use constexpr instead of inline if __cpp_constexpr >= 202406L. * g++.dg/cpp26/constexpr-new1.C: New test. * g++.dg/cpp26/constexpr-new2.C: New test. * g++.dg/cpp26/constexpr-new3.C: New test. * g++.dg/cpp26/feat-cxx26.C (__cpp_constexpr): Adjust expected value. libstdc++-v3/ * libsupc++/new (__glibcxx_want_constexpr_new): Define before including bits/version.h. (_GLIBCXX_PLACEMENT_CONSTEXPR): Define. (operator new, operator new[]): Use it for placement new instead of inline. * include/bits/version.def (constexpr_new): New FTM. * include/bits/version.h: Regenerate.
2024-08-07Daily bump.GCC Administrator1-0/+8
2024-08-06libstdc++: Fix some undeclared uses of uintptr_t [PR116247]Jonathan Wakely3-1/+3
libstdc++-v3/ChangeLog: PR libstdc++/116247 * include/bits/fs_path.h: Use __UINTPTR_TYPE__ instead of uintptr_t. * include/bits/shared_ptr_atomic.h: Likewise. * include/ext/pointer.h: Include <stdint.h>.
2024-08-04Daily bump.GCC Administrator1-0/+8
2024-08-03libstdc++: use concrete return type for std::forward_likePatrick Palka2-27/+26
Inspired by https://github.com/llvm/llvm-project/issues/101614 this inverts the relationship between forward_like and __like_t so that forward_like is defined in terms of __like_t and with a concrete return type. __like_t in turn is defined via partial specializations that pattern match on the const- and reference-ness of T. This turns out to be more SFINAE friendly and significantly cheaper to compile than the previous implementation. libstdc++-v3/ChangeLog: * include/bits/move.h (__like_impl): New metafunction. (__like_t): Redefine in terms of __like_impl. (forward_like): Redefine in terms of __like_t. * testsuite/20_util/forward_like/2_neg.cc: Don't expect error outside the immediate context anymore. Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2024-08-03Daily bump.GCC Administrator1-0/+5
2024-08-02libstdc++: Add missing <cstdint> to testJonathan Wakely1-0/+1
libstdc++-v3/ChangeLog: * testsuite/libstdc++-prettyprinters/shared_ptr.cc: Include <cstdint>.
2024-08-02Daily bump.GCC Administrator1-0/+53
2024-08-01libstdc++: Remove unused helper traitsJonathan Wakely2-10/+0
These are not used anywhere, we have more efficient variable templates for them instead. They're not documented as extensions, and are easy for users to write if they need them. libstdc++-v3/ChangeLog: * include/bits/utility.h (__is_in_place_type): Remove. * include/std/variant (__is_in_place_tag): Remove.
2024-08-01libstdc++: Remove unnecessary uses of <stdint.h>Jonathan Wakely4-10/+17
We don't need to include all of <stdint.h> when we only need uintptr_t from it. By using GCC's internal macro we avoid unnecessarily declaring everything in <stdint.h>. This helps users to avoid accidentally relying on those names being declared without explicitly including the header. libstdc++-v3/ChangeLog: * include/bits/align.h (align, assume_aligned): Use __UINTPTR_TYPE__ instead of uintptr_t. Do not include <stdint.h>. * include/bits/atomic_base.h (__atomic_ref): Likewise. * include/bits/atomic_wait.h (__waiter_pool_base::_S_for): Likewise. * include/std/atomic: Include <cstdint>.
2024-08-01libstdc++: Remove unused parameters from atomic impl detailsJonathan Wakely1-4/+2
libstdc++-v3/ChangeLog: * include/bits/atomic_base.h (__atomic_impl::compare_exchange_weak): Remove unused parameter. (__atomic_impl::compare_exchange_strong): Likewise.
2024-08-01libstdc++: Use memcmp to optimize std::bitset::_M_is_equal() [PR113807]Jonathan Wakely1-4/+10
As noted in the PR the compiler doesn't seem able to do this on its own, so we get better code at all optimization levels by using memcmp. libstdc++-v3/ChangeLog: PR libstdc++/113807 * include/std/bitset (bitset::_M_is_equal()): Use memcmp to optimize operator==.
2024-08-01libstdc++: Fix incomplete change to reduce iterations for simulatorsJonathan Wakely1-3/+3
This should have been done as part of r13-693-ge3b8b4f7814c54, but I only added the preprocessor logic and didn't use ARGS in the code. libstdc++-v3/ChangeLog: * testsuite/26_numerics/random/discrete_distribution/operators/values.cc: Use ARGS to limit number of iterations for simulators.
2024-08-01libstdc++: Constrain std::basic_string default constructor [PR113841]Jonathan Wakely3-0/+36
This is needed to avoid errors outside the immediate context when evaluating is_default_constructible_v<basic_string<C, T, A>> when A is not default constructible. This change is not sufficient to solve the problem because there are a large number of member functions which have a default argument that constructs an allocator. libstdc++-v3/ChangeLog: PR libstdc++/113841 * include/bits/basic_string.h (basic_string::basic_string()): Constrain so that it's only present if the allocator is default constructible. * include/bits/cow_string.h (basic_string::basic_string()): Likewise. * testsuite/21_strings/basic_string/cons/113841.cc: New test.
2024-08-01libstdc++: Remove noexcept from non-const std::basic_string::data() [PR99942]Jonathan Wakely1-1/+6
The C++17 non-const overload of data() allows modifying the string contents directly, so for the COW string we must do a copy-on-write to unshare it. That means allocating, which can throw, so it shouldn't be noexcept. libstdc++-v3/ChangeLog: PR libstdc++/99942 * include/bits/cow_string.h (data()): Change to noexcept(false).
2024-08-01libstdc++: Make dg-error pattern more accurateJonathan Wakely2-4/+4
Remove useless test variable and use a more accurate dg-error pattern so that only the ill-formed expression compilation error is considered. libstdc++-v3/ChangeLog: * testsuite/23_containers/map/operators/1_neg.cc (test01): Remove test variable and use 'no match' dg-error patter. * testsuite/23_containers/set/operators/1_neg.cc (test01): Likewise.
2024-08-01Daily bump.GCC Administrator1-0/+134
2024-07-31libstdc++: Fix unexpected compilation error in neg testsFrançois Dumont2-10/+8
Fix a compilation error that is not expected by the tests preserving the expected ones. The 'test' variable declaration is missing since commit a9260b7eb688df43a724e25421ba40f35a89fee9 that removed the test global variable in testsuite files. libstdc++-v3/ChangeLog: * testsuite/23_containers/map/operators/1_neg.cc (test01): Add test variable declaration. * testsuite/23_containers/set/operators/1_neg.cc (test01): Likewise.
2024-07-31libstdc++: Fix src/c++20/format.cc for non-gthreads targetsJonathan Wakely2-5/+14
libstdc++-v3/ChangeLog: * src/c++20/format.cc [!_GLIBCXX_HAS_GTHREADS] (mutex): Define dummy mutex type. * testsuite/std/time/format_localized.cc: Use loop variable instead of creating the same locale on every iteration.
2024-07-31libstdc++: drop bogus 'dg_do run' directiveSam James1-1/+0
We already have a valid 'dg-do run' (- vs _) directive, so drop the bogus one. libstdc++-v3/ChangeLog: * testsuite/28_regex/traits/char/translate.cc: Drop bogus 'dg_do run'.
2024-07-31libstdc++: Handle strerror returning nullJonathan Wakely1-1/+5
The linux man page for strerror says that some systems return NULL for an unknown error number. That violates the C and POSIX standards, but we can esily handle it to avoid a segfault. libstdc++-v3/ChangeLog: * src/c++11/system_error.cc (strerror_string): Handle non-conforming NULL return from strerror.
2024-07-31libstdc++: Only append "@euro" to locale names for Glibc testingJonathan Wakely1-1/+1
The testsuite automatically appends "@euro" to "xx.ISO8859-15" locale names on all targets except FreeBSD, DragonflyBSD, and NetBSD. It should only be for Glibc, not all non-BSD targets. libstdc++-v3/ChangeLog: * testsuite/lib/libstdc++.exp (check_v3_target_namedlocale): Only append "@euro" to ".ISO8859-15" locales for Glibc.
2024-07-31libstdc++: Bump __cpp_lib_format value for std::runtime_formatJonathan Wakely4-6/+6
We already supported this feature, but couldn't set the feature test macro accordingly because we were missing support for older features. Now that we support all the older <format> changes, we can set this to the correct value. libstdc++-v3/ChangeLog: * include/bits/version.def (format): Update value for C++26. * include/bits/version.h: Regenerate. * include/std/format (runtime_format, wruntime_format): Check __cpp_lib_format instead of __cplusplus. * testsuite/std/format/functions/format.cc: Update expected value of macro for C++26 mode.
2024-07-31libstdc++: Define C++26 member visit for std::basic_format_arg [PR110356]Jonathan Wakely7-6/+75
Implement the std::format changes from P2637R3. This adds visit member functions to std::basic_format_arg and deprecates the non-member function std::visit_format_arg. libstdc++-v3/ChangeLog: PR libstdc++/110356 * include/bits/c++config (_GLIBCXX26_DEPRECATED): Define. (_GLIBCXX26_DEPRECATED_SUGGEST): Define. * include/bits/version.def (format): Update for C++26. * include/bits/version.h: Regenerate. * include/std/format (basic_format_arg::visit): New member functions. (visit_format_arg): Add deprecated attribute. * testsuite/std/format/arguments/args.cc: Expect deprecated warnings. Check member visit. * testsuite/std/format/functions/format.cc: Update expected value for __cpp_lib_format macro. * testsuite/std/format/parse_ctx.cc: Add dg-warning for deprecation.
2024-07-31libstdc++: Define C++26 member visit for std::variant [PR110356]Jonathan Wakely5-2/+178
Implement the std::variant changes from P2637R3. libstdc++-v3/ChangeLog: PR libstdc++/110356 * include/bits/version.def (variant): Update for C++26. * include/bits/version.h: Regenerate. * include/std/variant (variant::visit): New member functions. * testsuite/20_util/variant/visit.cc: Check second alternative. * testsuite/20_util/variant/visit_member.cc: New test.
2024-07-31libstdc++: Implement C++26 type checking for std::format args [PR115776]Jonathan Wakely7-13/+347
Implement the changes from P2757R3, which enhance the parse context to be able to do type checking on format arguments, and to use that to ensure that args used for width and precisions are integral types. libstdc++-v3/ChangeLog: PR libstdc++/115776 * include/bits/version.def (format): Update for C++26. * include/bits/version.h: Regenerate. * include/std/format (basic_format_parse_context): Remove default argument from constructor and split into two constructors. Make the constructor taking size_t private for C++26 and later. (basic_format_parse_context::check_dynamic_spec): New member function template. (basic_format_parse_context::check_dynamic_spec_integral): New member function. (basic_format_parse_context::check_dynamic_spec_string): Likewise. (__format::_Spec::_S_parse_width_or_precision): Use check_dynamic_spec_integral. (__format::__to_arg_t_enum): New helper function. (basic_format_arg): Declare __to_arg_t_enum as friend. (__format::_Scanner): Define and use a derived parse context type. (__format::_Checking_scanner): Make arg types available to parse context. * testsuite/std/format/functions/format.cc: Check for new values of __cpp_lib_format macro. * testsuite/std/format/parse_ctx.cc: Check all members of basic_format_parse_context. * testsuite/std/format/parse_ctx_neg.cc: New test. * testsuite/std/format/string.cc: Add more checks for dynamic width and precision args.
2024-07-31libstdc++: Support P2510R3 "Formatting pointers" as a DR for C++20Jonathan Wakely5-20/+12
We already enable this for -std=gnu++20 but we can do it for -std=c++20 too. Both libc++ and MSVC also treat this change as a DR for C++20. Now that the previous change to the value of __cpp_lib_format is supported, we can finally update it to 202304 to indicate support for this feature too. libstdc++-v3/ChangeLog: * include/bits/version.def (format): Update value for P2510R3. * include/bits/version.h: Regenerate. * include/std/format (_GLIBCXX_P2518R3): Remove misspelled macro and check __glibcxx_format instead. * testsuite/std/format/functions/format.cc: Check value of the __cpp_lib_format macro for formatting pointers support. * testsuite/std/format/parse_ctx.cc: Likewise.
2024-07-31libstdc++: Handle encodings in localized chrono formatting [PR109162]Jonathan Wakely12-29/+459
This implements the C++23 paper P2419R2 (Clarify handling of encodings in localized formatting of chrono types). The requirement is that when the literal encoding is "a Unicode encoding form" and the formatting locale uses a different encoding, any locale-specific strings such as "août" for std::chrono::August should be converted to the literal encoding. Using the recently-added std::locale::encoding() function we can check the locale's encoding and then use iconv if a conversion is needed. Because nl_langinfo_l and iconv_open both allocate memory, a naive implementation would perform multiple allocations and deallocations for every snippet of locale-specific text that needs to be converted to UTF-8. To avoid that, a new internal locale::facet is defined to store the text_encoding and an iconv_t descriptor, which are then cached in the formatting locale. This requires access to the internals of a std::locale object in src/c++20/format.cc, so that new file needs to be compiled with -fno-access-control, as well as -std=gnu++26 in order to use std::text_encoding. Because the new std::text_encoding and std::locale::encoding() symbols are only in the libstdc++exp.a archive, we need to include src/c++26/text_encoding.cc in the main library, but not export its symbols yet. This means they can be used by the two new functions which are exported from the main library. The encoding conversions are done for C++20, treating it as a DR that resolves LWG 3656. With this change we can increase the value of the __cpp_lib_format macro for C++23. The value should be 202207 for P2419R2, but we already implement P2510R3 (Formatting pointers) so can use the value 202304. libstdc++-v3/ChangeLog: PR libstdc++/109162 * acinclude.m4 (libtool_VERSION): Update to 6:34:0. * config/abi/pre/gnu.ver: Disambiguate old patters. Add new GLIBCXX_3.4.34 symbol version and new exports. * configure: Regenerate. * include/bits/chrono_io.h (_ChronoSpec::_M_locale_specific): Add new accessor functions to use a reserved bit in _Spec. (__formatter_chrono::_M_parse): Use _M_locale_specific(true) when chrono-specs contains locale-dependent conversion specifiers. (__formatter_chrono::_M_format): Open iconv descriptor if conversion to UTF-8 will be needed. (__formatter_chrono::_M_write): New function to write a localized string with possible character conversion. (__formatter_chrono::_M_a_A, __formatter_chrono::_M_b_B) (__formatter_chrono::_M_p, __formatter_chrono::_M_r) (__formatter_chrono::_M_x, __formatter_chrono::_M_X) (__formatter_chrono::_M_locale_fmt): Use _M_write. * include/bits/version.def (format): Update value. * include/bits/version.h: Regenerate. * include/std/format (_GLIBCXX_P2518R3): Check feature test macro instead of __cplusplus. (basic_format_context): Declare __formatter_chrono as friend. * src/c++20/Makefile.am: Add new file. * src/c++20/Makefile.in: Regenerate. * src/c++20/format.cc: New file. * testsuite/std/time/format_localized.cc: New test. * testsuite/util/testsuite_abi.cc: Add new symbol version.
2024-07-31Daily bump.GCC Administrator1-0/+68
2024-07-30libstdc++: Fix formatter for low-resolution chrono::zoned_time (LWG 4124)Jonathan Wakely2-3/+13
This implements the proposed resolution of LWG 4124, so that low-resolution chrono::zoned_time objects can be formatted. The formatter for zoned_time<D, P> needs to account for get_local_time returning local_time<common_type_t<D, seconds>> not local_time<D>. libstdc++-v3/ChangeLog: * include/bits/chrono_io.h (__local_time_fmt_for): New alias template. (formatter<zoned_time<D, P>>): Use __local_time_fmt_for. * testsuite/std/time/zoned_time/io.cc: Check zoned_time<minutes> can be formatted.
2024-07-30libstdc++: Fix std::format output for std::chrono::zoned_timeJonathan Wakely6-17/+130
When formatting a chrono::zoned_time with an empty chrono-specs, we were only formatting its _M_time member, but the ostream insertion operator uses the format "{:L%F %T %Z}" which includes the time zone abbreviation. The %Z should also be used when formatting with an empty chrono-specs. This commit makes _M_format_to_ostream handle __local_time_fmt specializations directly, rather than calling itself recursively to format the _M_time member. We need to be able to customize the output of _M_format_to_ostream for __local_time_fmt, because we use that type for gps_time and tai_time as well as for zoned_time and __local_time_fmt. When formatting gps_time and tai_time we don't want to include the time zone abbreviation in the "{}" output, but for zoned_time we do want to. We can reuse the __is_neg flag passed to _M_format_to_ostream (via _M_format) to say that we want the time zone abbreviation. Currently the __is_neg flag is only used for duration specializations, so it's available for __local_time_fmt to use. In addition to fixing the zoned_time output to use %Z, this commit also changes the __local_time_fmt output to use %Z. Previously it didn't use it, just like zoned_time. The standard doesn't actually say how to format local-time-format-t for an empty chrono-specs, but this behaviour seems sensible and is what I'm proposing as part of LWG 4124. While testing this I noticed that some chrono types were not being tested with empty chrono-specs, so this adds more tests. I also noticed that std/time/clock/local/io.cc was testing tai_time instead of local_time, which was completely wrong. That's fixed now too. libstdc++-v3/ChangeLog: * include/bits/chrono_io.h (__local_fmt_t): Remove unused declaration. (__formatter_chrono::_M_format_to_ostream): Add explicit handling for specializations of __local_time_fmt, including the time zone abbreviation in the output if __is_neg is true. (formatter<chrono::tai_time<D>>::format): Add comment. (formatter<chrono::gps_time<D>>::format): Likewise. (formatter<chrono::__detail::__local_time_fmt::format): Call _M_format with true for the __is_neg flag. * testsuite/std/time/clock/gps/io.cc: Remove unused variable. * testsuite/std/time/clock/local/io.cc: Fix test error that checked tai_time instead of local_time. Add tests for local-time-format-t formatting. * testsuite/std/time/clock/system/io.cc: Check empty chrono-specs. * testsuite/std/time/clock/tai/io.cc: Likewise. * testsuite/std/time/zoned_time/io.cc: Likewise.
2024-07-30libstdc++: Implement LWG 3886 for std::optional and std::expectedJonathan Wakely4-10/+126
This uses remove_cv_t<T> for the default template argument used for deducing a type for a braced-init-list used with std::optional and std::expected. libstdc++-v3/ChangeLog: * include/std/expected (expected(U&&), operator=(U&&)) (value_or): Use remove_cv_t on default template argument, as per LWG 3886. * include/std/optional (optional(U&&), operator=(U&&)) (value_or): Likewise. * testsuite/20_util/expected/lwg3886.cc: New test. * testsuite/20_util/optional/cons/lwg3886.cc: New test.
2024-07-30libstdc++: Fix name of source file in commentJonathan Wakely1-1/+1
libstdc++-v3/ChangeLog: * src/c++17/fs_ops.cc: Fix file name in comment.
2024-07-30libstdc++: Fix overwriting files with fs::copy_file on WindowsJonathan Wakely5-33/+199
There are no inode numbers on Windows filesystems, so stat_type::st_ino is always zero and the check for equivalent files in do_copy_file was incorrectly identifying distinct files as equivalent. This caused copy_file to incorrectly report errors when trying to overwrite existing files. The fs::equivalent function already does the right thing on Windows, so factor that logic out into a new function that can be reused by fs::copy_file. The tests for fs::copy_file were quite inadequate, so this also adds checks for that function's error conditions. libstdc++-v3/ChangeLog: * src/c++17/fs_ops.cc (auto_win_file_handle): Change constructor parameter from const path& to const wchar_t*. (fs::equiv_files): New function. (fs::equivalent): Use equiv_files. * src/filesystem/ops-common.h (fs::equiv_files): Declare. (do_copy_file): Use equiv_files. * src/filesystem/ops.cc (fs::equiv_files): Define. (fs::copy, fs::equivalent): Use equiv_files. * testsuite/27_io/filesystem/operations/copy.cc: Test overwriting directory contents recursively. * testsuite/27_io/filesystem/operations/copy_file.cc: Test overwriting existing files.
2024-07-30libstdc++: Fix fs::hard_link_count behaviour on MinGW [PR113663]Lennox Shou Hao Ho2-22/+74
std::filesystem::hard_link_count() always returns 1 on mingw-w64ucrt-11.0.1-r3 on Windows 10 19045 hard_link_count() queries _wstat64() on MinGW-w64 The MSFT documentation claims _wstat64() will always return 1 *non*-NTFS volumes https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2013/14h5k7ff(v=vs.120) My tests suggest that is not always true - hard_link_count()/_wstat64() still returns 1 on NTFS. GetFileInformationByHandle does return the correct result of 2. Please see the PR for a minimal repro. This patch changes the Windows implementation to always call GetFileInformationByHandle. PR libstdc++/113663 libstdc++-v3/ChangeLog: * src/c++17/fs_ops.cc (fs::equivalent): Moved helper class auto_handle to anonymous namespace as auto_win_file_handle. (fs::hard_link_count): Changed Windows implementation to use information provided by GetFileInformationByHandle which is more reliable. * testsuite/27_io/filesystem/operations/hard_link_count.cc: New test. Signed-off-by: "Lennox" Shou Hao Ho <lennoxhoe@gmail.com> Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2024-07-30Daily bump.GCC Administrator1-0/+4
2024-07-29Polish libstdc++ 'dg-final' action 'file-io-diff'Thomas Schwinge1-8/+11
Follow-up to recent commit 515da03a838db05443ebcc4c543a405bed764188 "libstdc++: Add file-io-diff to replace @diff@ markup in I/O tests". Currently, if a 'dg-final' action 'file-io-diff' passes, we print nothing (should: 'PASS: [...]'), but if it fails, we just print: 'FAIL: files differ', for example ('*.log' file): [...] FAIL: 27_io/basic_ostream/inserters_other/wchar_t/2.cc -std=gnu++17 (test for excess errors) [...] UNRESOLVED: 27_io/basic_ostream/inserters_other/wchar_t/2.cc -std=gnu++17 compilation failed to produce executable diff: wostream_inserter_other_in.txt: No such file or directory diff: wostream_inserter_other_out.txt: No such file or directory FAIL: files differ diff: wostream_inserter_other_in.txt: No such file or directory diff: wostream_inserter_other_out.txt: No such file or directory When later the '*.sum' files get sorted, these 'FAIL: files differ' instances aren't grouped anymore with the other test cases' results, but they appear en bloc, lexically sorted between ('e[...]' and 's[...]'), for example: [...] PASS: ext/vstring/types/23767.cc -std=gnu++17 (test for excess errors) FAIL: files differ FAIL: files differ FAIL: files differ PASS: special_functions/01_assoc_laguerre/check_nan.cc -std=gnu++17 (test for excess errors) [...] Also, we shouldn't emit the actual 'diff' into the '*.sum' file, but just into the '*.log* file, and there's no need for 'spawn'/'expect', as we're not matching any specific messages. libstdc++-v3/ * testsuite/lib/libstdc++.exp (file-io-diff): Polish.