`<type_traits>`: Investigate one `reference_constructs_from_temporary` case
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 11.1k
- Forks
- 1.7k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 22
Description
After @joemmett fixed internal VSO-2742607 "C1XX __reference_constructs_from_temporary mishandles a couple of cases", there's a remaining point of divergence between C1XX and Clang in the test cases added by #5537. Fully reduced:
D:\GitHub\STL\out\x64>type meow.cpp
#include <type_traits>
struct to_int_prvalue_implicitly {
explicit(false) operator int() const;
};
struct to_int_prvalue_explicitly {
explicit(true) operator int() const;
};
static_assert(std::reference_constructs_from_temporary_v<const int&, to_int_prvalue_implicitly>);
static_assert(std::reference_constructs_from_temporary_v<const int&, to_int_prvalue_explicitly>);
D:\GitHub\STL\out\x64>cl
Microsoft (R) C/C++ Optimizing Compiler Version 19.51.36223.2 for x64 (PREVIEW)
Copyright (C) Microsoft Corporation. All rights reserved.
usage: cl [ option... ] filename... [ /link linkoption... ]
D:\GitHub\STL\out\x64>cl /EHsc /nologo /W4 /std:c++latest /diagnostics:caret /c meow.cpp
meow.cpp
meow.cpp(12,20): error C2607: static assertion failed
static_assert(std::reference_constructs_from_temporary_v<const int&, to_int_prvalue_explicitly>);
^
D:\GitHub\STL\out\x64>clang-cl -v
clang version 20.1.8
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files\Microsoft Visual Studio\18\Insiders\VC\Tools\Llvm\x64\bin
D:\GitHub\STL\out\x64>clang-cl /EHsc /nologo /W4 /std:c++latest /c meow.cpp
D:\GitHub\STL\out\x64>
I don't want to try to summarize Jonathan's analysis of this case, since I'll probably mangle it. I believe this is related to a Core issue that we didn't get a response about on the CWG reflector, and we haven't yet rounded up a Clang dev to talk to Jonathan and see if we can get some kind of agreement about what the correct answer should be here. So, I'm filing this tracking issue.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the reduced meow.cpp example with cl and clang-cl using the commands in the issue, then read the type_traits cases added by #5537. Investigate the remaining disagreement around reference_constructs_from_temporary and the related Core issue or CWG discussion. Done means the correct behavior is agreed with the relevant compiler experts and the implementation and regression coverage are aligned.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100