From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id ED0C438449C2; Fri, 3 May 2024 19:39:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ED0C438449C2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1714765174; bh=NEirOHhtyeI2FlbTiCur4ilH5oPzKwdtIvjooAYNH7w=; h=From:To:Subject:Date:From; b=PUndQbLq8YlbPZmcIDTR8sTUZLjG4CRgwNye16kkfHwrIMd2GusZp066m9oNC5oDw hQiPWOZ/lw8h9ehrlPzXEQQAykal8l4vt9YPi/GNNXUfcjzWdIzk+V61Myz86qR+a+ dTLOLiq7teWNxViaEf490myuwDZusKUY6WbGOAsE= From: "liuxf19 at 163 dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/114940] New: std::generator relies on an optional overload of operator delete Date: Fri, 03 May 2024 19:39:34 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: liuxf19 at 163 dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D114940 Bug ID: 114940 Summary: std::generator relies on an optional overload of operator delete Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: liuxf19 at 163 dot com Target Milestone: --- The bug report #114891 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D114891 discussed the impact of is_pointer_interconvertible_base_of_v on using std::generator with clang++ and libstdc++. There's another issue when std::generator in libstdc++ is used by other compilers such as clang++. In the header , an overload of operator delete: void operator delete ( void* ptr, std::size_t sz ) noexcept; However, this is an OPTIONAL feature whose feature test macro is __cpp_sized_deallocation macro. Some compilers especially clang++, even the newest clang trunk (which is avaiable at https://godbolt.org, and the vers= ion is 19.0.0) didn't implement this macro. For example, the code below: #include int main() { #ifndef __cpp_sized_deallocation static_assert(false, "no __cpp_sized_deallocation"); #endif } compiled with: clang++ -std=3Dc++23 -stdlib=3Dlibstdc++ will cause the following errors: :5:19: error: static assertion failed: no __cpp_sized_deallocation 5 | static_assert(false, "no __cpp_sized_deallocation"); | ^~~~~ 1 error generated. ASM generation compiler returned: 1 :5:19: error: static assertion failed: no __cpp_sized_deallocation 5 | static_assert(false, "no __cpp_sized_deallocation"); | ^~~~~ 1 error generated. See https://gcc.godbolt.org/z/MocWxMKz6 for details. And thus there's no this overload with clang++. But the std::generator in libstdc++ relies on this overload, which also cau= ses clang++ cannot use std::generator in libstdc++ (even after clang++ 19 provi= ded is_pointer_interconvertible_base_of discussed in #114891). The following code: #include #include std::generator iota(int n) { for (int i =3D 0; i < n; ++i) { co_yield i; } } int main() { for (auto i : iota(10)) { } return 0; } compiled with: clang++ -std=3Dc++23 -stdlib=3Dlibstdc++ And the compilation errors: In file included from main.cpp:16: /usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/generato= r:606:6: error: no matching function for call to 'operator delete' 606 | ::operator delete(__ptr, _M_alloc_size(__sz)); | ^~~~~~~~~~~~~~~~~ See https://gcc.godbolt.org/z/xjMGaq36a for details. Note that there's no restrictions that std::generator must depends on this overload of operator delete in ISO C++. This may cause clang++ or other compilers cannot use std::generator in libstdc++.=