From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E7EC6385843B; Wed, 25 Aug 2021 21:29:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E7EC6385843B From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/102064] Wrong assignable check in uninitialized_fill and uninitialized_fill_n Date: Wed, 25 Aug 2021 21:29:07 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: redi at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Aug 2021 21:29:08 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102064 --- Comment #2 from CVS Commits --- The master branch has been updated by Jonathan Wakely : https://gcc.gnu.org/g:ead408529d7a69873a7c14dd12fa043cd5862253 commit r12-3147-gead408529d7a69873a7c14dd12fa043cd5862253 Author: Jonathan Wakely Date: Wed Aug 25 21:10:48 2021 +0100 libstdc++: Fix conditions for optimizing uninitialized algos [PR102064] While laying some groundwork for constexpr std::vector, I noticed some bugs in the std::uninitialized_xxx algorithms. The conditions being checked for optimizing trivial cases were not quite right, as shown in the examples in the PR. This consolidates the checks into a single macro. The macro has appropriate definitions for C++98 or for later standards, to avoid a #if everywhere the checks are used. For C++11 and later the check makes a call to a new function doing a static_assert to ensure we don't use assignment in cases where construction would have been invalid. Extracting that check to a separate function will be useful for constexpr std::vector, as that can't use std::uninitialized_copy directly because it isn't constexpr). The consolidated checks mean that some slight variations in static assert message are gone, as there is only one place that does the assert now. That required adjusting some tests. As part of that the redundant 89164_c++17.cc test was merged into 89164.cc which is compiled as C++17 by default now, but can also use other -std options if the C++17-specific error is made conditional with a target selector. Signed-off-by: Jonathan Wakely libstdc++-v3/ChangeLog: PR libstdc++/102064 * include/bits/stl_uninitialized.h (_GLIBCXX_USE_ASSIGN_FOR_INI= T): Define macro to check conditions for optimizing trivial cases. (__check_constructible): New function to do static assert. (uninitialized_copy, uninitialized_fill, uninitialized_fill_n): Use new macro. * testsuite/20_util/specialized_algorithms/uninitialized_copy/1= .cc: Adjust dg-error pattern. * testsuite/23_containers/vector/cons/89164.cc: Likewise. Add C++17-specific checks from 89164_c++17.cc. * testsuite/23_containers/vector/cons/89164_c++17.cc: Removed. * testsuite/20_util/specialized_algorithms/uninitialized_copy/102064.cc: New test. * testsuite/20_util/specialized_algorithms/uninitialized_copy_n/102064.cc: New test. * testsuite/20_util/specialized_algorithms/uninitialized_fill/102064.cc: New test. * testsuite/20_util/specialized_algorithms/uninitialized_fill_n/102064.cc: New test.=