std::common_reference uses decltype to the ternary operator ?:
Otherwise, if
decltype(false? val<T1>() : val<T2>()), where val is a function templatetemplate<class T> T val();, is a valid type, then the member type type names that type;
But MSVC says decltype(false? val<int&&>() : val<int&&>()) is int in the below code in below C++20.
#include <type_traits>
template<typename T>
T val();
int main() {
static_assert(std::is_same<int&&, decltype(val<int&&>())>::value, "1");
static_assert(std::is_same<int&&, decltype(false?val<int&&>():val<int&&>())>::value, "2");
}
https://godbolt.org/z/KE9PnGvd5
What is a correct behavior?
Is this an MSVC defect?