[Bug c++/96095] New: decltype((r)) inside of lambda with copy capture gives wrong type
barry.revzin at gmail dot com
gcc-bugzilla@gcc.gnu.org
Tue Jul 7 15:06:05 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96095
Bug ID: 96095
Summary: decltype((r)) inside of lambda with copy capture gives
wrong type
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: barry.revzin at gmail dot com
Target Milestone: ---
Couldn't find a dupe for this one. The example from what is now
[expr.prim.id.unqual]/2 (http://eel.is/c++draft/expr.prim.id.unqual#2) doesn't
have the expected behavior:
template <typename T, typename U>
inline constexpr bool is_same_v = false;
template <typename T>
inline constexpr bool is_same_v<T, T> = true;
void f(float x, float& r) {
[=] {
static_assert(is_same_v<decltype(x), float>);
static_assert(is_same_v<decltype((x)), float const&>);
static_assert(is_same_v<decltype(r), float&>);
static_assert(is_same_v<decltype((r)), float const&>); // error
}();
}
gcc reports decltype((r)) to be float&, not float const& here.
More information about the Gcc-bugs
mailing list