Clang rejects implicit conversion from an integer lvalue reference to another integer rvalue reference via a conversion operator
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
The following program is rejected by clang but accepted by both gcc and msvc. [Demo](https://godbolt.org/z/1ofEdhKzW)
```
#include
struct S
{
operator long &() const
{
exit(0);
}
};
int main() { int &&a((S())); }
```
Clang says:
```
:9:20: error: no viable conversion from 'S' to 'int'
9 | int main() { int &&a((S())); }
| ^ ~~~~~
:4:2: note: candidate function
4 | operator long &() const {
|
```
Contributor guide
Research direction
Start with the reduced C++ reproducer in the issue and compare Clang's diagnostic with the accepted behavior shown for GCC and MSVC in the linked Compiler Explorer demo. Trace the compiler's implicit-conversion handling for the conversion operator, then verify that the reproducer is accepted without the reported error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100