Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libc++] std::declval gives wrong result for cv void #61232

Closed
fsb4000 opened this issue Mar 7, 2023 · 5 comments
Closed

[libc++] std::declval gives wrong result for cv void #61232

fsb4000 opened this issue Mar 7, 2023 · 5 comments
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

Comments

@fsb4000
Copy link
Member

fsb4000 commented Mar 7, 2023

@frederick-vs-ja found that std::declval works wrongly for the 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/rc483sWPo

@fsb4000 fsb4000 added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Mar 7, 2023
@shafik
Copy link
Collaborator

shafik commented Mar 7, 2023

It looks like libstdc++ is also doing the same thing, have you also filed a bug there as well?

I have to look up the wording to see what we expect here.

@fsb4000
Copy link
Member Author

fsb4000 commented Mar 7, 2023

Yes, I have filed https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109049

@fsb4000
Copy link
Member Author

fsb4000 commented Mar 7, 2023

It looks like they don't want to fix that.

Should we file a LWG issue to fix the C++ standard instead?

@frederick-vs-ja
Copy link
Contributor

I've mailed to LWG Chair to request legitimation of libc++ and libstdc++'s current strategy.

@EricWF
Copy link
Member

EricWF commented Mar 20, 2023

The provided reproducer is not well-defined.
I agree with Jonathan Wakely's position on the libstdc++ bug that was filed.

There's a defect in the standard here, but the defect is that the standard fails to explicitly call out this example as being ill-formed because it depends on the exact signature of declval which is an implementation detail. As Wakely points out, there is already language which disallows formation of a pointer/reference to the function, and that should be extended to include inspecting the exact type.

@EricWF EricWF closed this as completed Mar 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

No branches or pull requests

4 participants