public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug libstdc++/109049] New: std::declval gives wrong result for cv void @ 2023-03-07 6:18 fsb4000 at yandex dot ru 2023-03-07 12:23 ` [Bug libstdc++/109049] " redi at gcc dot gnu.org ` (3 more replies) 0 siblings, 4 replies; 5+ messages in thread From: fsb4000 at yandex dot ru @ 2023-03-07 6:18 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109049 Bug ID: 109049 Summary: std::declval gives wrong result for cv void Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: fsb4000 at yandex dot ru Target Milestone: --- A. Jiang <de34@live.cn> found that: Quote: "The return type is... cursed for cv void. It seems that decltype(std::declval<const void>) should be const void() (until C++17) / const void() noexcept (since C++17) (same for volatile void and const volatile void), but the cv-qualifiers are dropped" Code example: #include <utility> #include <type_traits> int main() { static_assert(std::is_same_v<decltype(std::declval<const void>), const void () noexcept>); static_assert(std::is_same_v<decltype(std::declval<volatile void>), volatile void () noexcept>); } https://gcc.godbolt.org/z/TMe3v9sxh I've created the same issue for libc++: https://github.com/llvm/llvm-project/issues/61232 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libstdc++/109049] std::declval gives wrong result for cv void 2023-03-07 6:18 [Bug libstdc++/109049] New: std::declval gives wrong result for cv void fsb4000 at yandex dot ru @ 2023-03-07 12:23 ` redi at gcc dot gnu.org 2023-03-07 12:32 ` redi at gcc dot gnu.org ` (2 subsequent siblings) 3 siblings, 0 replies; 5+ messages in thread From: redi at gcc dot gnu.org @ 2023-03-07 12:23 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109049 --- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- Who cares? Taking the address of std::declval is forbidden, and you can't call that specialization anyway. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libstdc++/109049] std::declval gives wrong result for cv void 2023-03-07 6:18 [Bug libstdc++/109049] New: std::declval gives wrong result for cv void fsb4000 at yandex dot ru 2023-03-07 12:23 ` [Bug libstdc++/109049] " redi at gcc dot gnu.org @ 2023-03-07 12:32 ` redi at gcc dot gnu.org 2023-03-07 15:07 ` de34 at live dot cn 2023-03-07 15:43 ` redi at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: redi at gcc dot gnu.org @ 2023-03-07 12:32 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109049 --- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> --- The reason it behaves this way is that we define declval as: template<typename _Tp> auto declval() noexcept -> decltype(__declval<_Tp>(0)); and decltype(__declval<_Tp>(0)) drops the cv-qualifiers. This implementation is much faster to compile, and so we're not going to stop using it to "fix" the useless testcase in this bug. Nobody cares about decltype(std::declval<const void>) but they do care about compile times. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libstdc++/109049] std::declval gives wrong result for cv void 2023-03-07 6:18 [Bug libstdc++/109049] New: std::declval gives wrong result for cv void fsb4000 at yandex dot ru 2023-03-07 12:23 ` [Bug libstdc++/109049] " redi at gcc dot gnu.org 2023-03-07 12:32 ` redi at gcc dot gnu.org @ 2023-03-07 15:07 ` de34 at live dot cn 2023-03-07 15:43 ` redi at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: de34 at live dot cn @ 2023-03-07 15:07 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109049 --- Comment #3 from Jiang An <de34 at live dot cn> --- I've mailed to LWG Chair to request legitimation of libc++ and libstdc++'s current strategy. ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libstdc++/109049] std::declval gives wrong result for cv void 2023-03-07 6:18 [Bug libstdc++/109049] New: std::declval gives wrong result for cv void fsb4000 at yandex dot ru ` (2 preceding siblings ...) 2023-03-07 15:07 ` de34 at live dot cn @ 2023-03-07 15:43 ` redi at gcc dot gnu.org 3 siblings, 0 replies; 5+ messages in thread From: redi at gcc dot gnu.org @ 2023-03-07 15:43 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109049 --- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> --- I thought it was already allowed, because std::declval is not an addressable function ([namespace.std]) but that only covers forming pointers and references to functions. We should extend that to cover this case. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-03-07 15:43 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-03-07 6:18 [Bug libstdc++/109049] New: std::declval gives wrong result for cv void fsb4000 at yandex dot ru 2023-03-07 12:23 ` [Bug libstdc++/109049] " redi at gcc dot gnu.org 2023-03-07 12:32 ` redi at gcc dot gnu.org 2023-03-07 15:07 ` de34 at live dot cn 2023-03-07 15:43 ` redi at gcc dot gnu.org
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).