You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The text was updated successfully, but these errors were encountered:
ldionne
added
c++26
libc++
libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
lwg-issue
this is an issue that was filed to the Library Working Group
labels
Dec 2, 2024
./bin/clang++ -std=c++26 -stdlib=libc++ -nostdinc++ -I ./include/c++/v1 -L ./lib/libc++ -Wl,-rpath,./lib p.cpp
In file included from p.cpp:2:
In file included from ./include/c++/v1/iostream:46:
In file included from ./include/c++/v1/istream:170:
In file included from ./include/c++/v1/__ostream/basic_ostream.h:18:
./include/c++/v1/__memory/unique_ptr.h:265:12: error: returning reference to local temporary object
265 | return *__ptr_;
| ^~~~~~~
p.cpp:15:11: note: in instantiation of member function 'std::unique_ptr<const int, deleter>::operator*' requested here
15 | int i = *p; // undefined
| ^
1 error generated.
This is due to C++26 core language change P2748R5 - Disallow Binding a Returned Glvalue to a Temporary.
But the resolution makes sense in C++23. Perhaps we should add static_assert in C++23 (or an even earlier) mode using __reference_converts_from_temporary (as reference_converts_from_temporary_v isn't implemented yet).
Thanks, I added it but the error message is error: indirection requires pointer operand ('std::unique_ptr<const int, deleter>' invalid)
Is this correct?
Link: https://wg21.link/LWG4148
The text was updated successfully, but these errors were encountered: