[Bug libstdc++/114367] std::vector constexpr initialization doesn't start lifetime of array members
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114367 Jonathan Wakely changed: What|Removed |Added Resolution|--- |FIXED Status|ASSIGNED|RESOLVED --- Comment #7 from Jonathan Wakely --- Fixed for 12.4 and 13.3
[Bug libstdc++/114367] std::vector constexpr initialization doesn't start lifetime of array members
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114367 --- Comment #6 from GCC Commits --- The releases/gcc-12 branch has been updated by Jonathan Wakely : https://gcc.gnu.org/g:5c2c5805304da2436f4a749d357eee34eae9d792 commit r12-10537-g5c2c5805304da2436f4a749d357eee34eae9d792 Author: Jonathan Wakely Date: Mon Mar 18 13:00:17 2024 + libstdc++: Begin lifetime of storage in std::vector [PR114367] This doesn't cause a problem with GCC, but Clang correctly diagnoses a bug in the code. The objects in the allocated storage need to begin their lifetime before we start using them. This change uses the allocator's construct function instead of using std::construct_at directly, in order to support fancy pointers. libstdc++-v3/ChangeLog: PR libstdc++/114367 * include/bits/stl_bvector.h (_M_allocate): Use allocator's construct function to begin lifetime of words. (cherry picked from commit 16afbd9c9c4282d56062cef95e6eccfdcf3efe03)
[Bug libstdc++/114367] std::vector constexpr initialization doesn't start lifetime of array members
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114367 --- Comment #5 from GCC Commits --- The releases/gcc-13 branch has been updated by Jonathan Wakely : https://gcc.gnu.org/g:d8d71b19f0b1e28fd6d413a6874ec55c568865b0 commit r13-8568-gd8d71b19f0b1e28fd6d413a6874ec55c568865b0 Author: Jonathan Wakely Date: Mon Mar 18 13:00:17 2024 + libstdc++: Begin lifetime of storage in std::vector [PR114367] This doesn't cause a problem with GCC, but Clang correctly diagnoses a bug in the code. The objects in the allocated storage need to begin their lifetime before we start using them. This change uses the allocator's construct function instead of using std::construct_at directly, in order to support fancy pointers. libstdc++-v3/ChangeLog: PR libstdc++/114367 * include/bits/stl_bvector.h (_M_allocate): Use allocator's construct function to begin lifetime of words. (cherry picked from commit 16afbd9c9c4282d56062cef95e6eccfdcf3efe03)
[Bug libstdc++/114367] std::vector constexpr initialization doesn't start lifetime of array members
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114367 --- Comment #4 from GCC Commits --- The master branch has been updated by Jonathan Wakely : https://gcc.gnu.org/g:16afbd9c9c4282d56062cef95e6eccfdcf3efe03 commit r14-9545-g16afbd9c9c4282d56062cef95e6eccfdcf3efe03 Author: Jonathan Wakely Date: Mon Mar 18 13:00:17 2024 + libstdc++: Begin lifetime of storage in std::vector [PR114367] This doesn't cause a problem with GCC, but Clang correctly diagnoses a bug in the code. The objects in the allocated storage need to begin their lifetime before we start using them. This change uses the allocator's construct function instead of using std::construct_at directly, in order to support fancy pointers. libstdc++-v3/ChangeLog: PR libstdc++/114367 * include/bits/stl_bvector.h (_M_allocate): Use allocator's construct function to begin lifetime of words.
[Bug libstdc++/114367] std::vector constexpr initialization doesn't start lifetime of array members
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114367 Jonathan Wakely changed: What|Removed |Added Target Milestone|--- |12.4 Keywords||rejects-valid Assignee|unassigned at gcc dot gnu.org |redi at gcc dot gnu.org Status|NEW |ASSIGNED
[Bug libstdc++/114367] std::vector constexpr initialization doesn't start lifetime of array members
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114367 --- Comment #3 from Jonathan Wakely --- Yeah this needs to use construct_at
[Bug libstdc++/114367] std::vector constexpr initialization doesn't start lifetime of array members
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114367 Andrew Pinski changed: What|Removed |Added Last reconfirmed||2024-03-16 Ever confirmed|0 |1 Status|UNCONFIRMED |NEW --- Comment #2 from Andrew Pinski --- (In reply to Andrew Pinski from comment #1) > Hmm: > > _Bit_pointer __p = _Bit_alloc_traits::allocate(_M_impl, > _S_nword(__n)); > #if __cpp_lib_is_constant_evaluated > if (std::is_constant_evaluated()) > { > __n = _S_nword(__n); > for (size_t __i = 0; __i < __n; ++__i) > __p[__i] = 0ul; > } > #endif > > Maybe I misunderstand how this should work. Oh yes see https://github.com/llvm/llvm-project/issues/46391 So yes this is a GCC bug with the above.
[Bug libstdc++/114367] std::vector constexpr initialization doesn't start lifetime of array members
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114367 --- Comment #1 from Andrew Pinski --- Hmm: _Bit_pointer __p = _Bit_alloc_traits::allocate(_M_impl, _S_nword(__n)); #if __cpp_lib_is_constant_evaluated if (std::is_constant_evaluated()) { __n = _S_nword(__n); for (size_t __i = 0; __i < __n; ++__i) __p[__i] = 0ul; } #endif Maybe I misunderstand how this should work.