For the following test case, the MSVC Compiler 19.52 Preview reports false while Clang 22.1.3 reports true. We believe that Clang is wrong:
(Click to expand version info)
C:\Temp>"%ProgramFiles%\Microsoft Visual Studio\18\Insiders\VC\Auxiliary\Build\vcvarsall.bat" x64 -vcvars_ver=preview
**********************************************************************
** Visual Studio 2026 Developer Command Prompt v18.7.0-insiders
** Copyright (c) 2026 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
C:\Temp>cl
Microsoft (R) C/C++ Optimizing Compiler Version 19.52.36405.1 for x64 (PREVIEW)
Copyright (C) Microsoft Corporation. All rights reserved.
usage: cl [ option... ] filename... [ /link linkoption... ]
C:\Temp>clang-cl -v
clang version 22.1.3 (https://github.com/llvm/llvm-project e9846648fd6183ee6d8cbdb4502213fcf902a211)
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files\Microsoft Visual Studio\18\Insiders\VC\Tools\Llvm\x64\bin
#include <print>
#include <type_traits>
using namespace std;
int main() {
using Obj = int[1];
constexpr bool val = reference_constructs_from_temporary_v<const Obj&, volatile Obj>;
#ifdef __clang__
println("Clang: {}", val);
#else
println("MSVC: {}", val);
#endif
}
C:\Temp>cl /EHsc /nologo /W4 /std:c++latest reduced.cpp && reduced
reduced.cpp
MSVC: false
C:\Temp>clang-cl /EHsc /nologo /W4 /std:c++latest reduced.cpp && reduced
Clang: true
Why is Clang wrong? See https://godbolt.org/z/8erKjbjsf which shows that all compilers (GCC 16, Clang 22, MSVC 19.50) agree that this is ill-formed:
int main() {
using Obj = int[1];
using U = volatile Obj;
const Obj& p(U{});
}
N5046 [tab:meta.unary.prop] specifies reference_constructs_from_temporary<T, U> as "T is a reference type, and the initialization T t(VAL<U>); is well-formed and binds t to a temporary object whose lifetime is extended (6.8.7)."
Because this initialization isn't well-formed, the type trait must report false. Note that GCC 16 behaves like MSVC and reports false, see https://godbolt.org/z/6fbTsnona .
Likely related to #142554 which implemented LWG-3819 "reference_meows_from_temporary should not use is_meowible".
For the following test case, the MSVC Compiler 19.52 Preview reports
falsewhile Clang 22.1.3 reportstrue. We believe that Clang is wrong:(Click to expand version info)
Why is Clang wrong? See https://godbolt.org/z/8erKjbjsf which shows that all compilers (GCC 16, Clang 22, MSVC 19.50) agree that this is ill-formed:
N5046 [tab:meta.unary.prop] specifies
reference_constructs_from_temporary<T, U>as "Tis a reference type, and the initializationT t(VAL<U>);is well-formed and bindstto a temporary object whose lifetime is extended (6.8.7)."Because this initialization isn't well-formed, the type trait must report
false. Note that GCC 16 behaves like MSVC and reportsfalse, see https://godbolt.org/z/6fbTsnona .Likely related to #142554 which implemented LWG-3819 "
reference_meows_from_temporaryshould not useis_meowible".