On Tue, 10 Dec 2024 at 00:59, Giuseppe D'Angelo <giuseppe.dang...@kdab.com> wrote: > > Hello, > > The attached patch fixes a compile error when converting a weak_ptr of > array type to a compatible type, for instance: > > std::weak_ptr<int [42]> wptr; > std::weak_ptr<int []> wptr2 = wptr; // ERROR > > https://gcc.godbolt.org/z/EWYb73Mvf > > The reason seems to be a typo: the inner __weak_ptr class has a lock() > implementation which doesn't work with arrays because it accidentally > uses `element_type` instead of `_Tp`. That lock() (and *not* > std::weak_ptr::lock(), which is instead fine) is called by the > converting constructors of __weak_ptr and that causes the compile error. > > I'm not sure if this has been already reported somewhere.
I don't think so, not that I can remember. > Tested on x86-64 Linux. The newer version of this patch at https://forge.sourceware.org/gcc/gcc-TEST/pulls/35 is OK for trunk, thanks. We should consider it for backporting too, since it's a C++17 feature that isn't working correctly.