llvm / llvm/llvm-project

Clang produces different output based on whether conversion function is explicitly called or not

Open
#218,096 4 comments 0 reactions 0 assignees View on GitHub
clang:frontend diverges-from:edg diverges-from:gcc diverges-from:msvc
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Consider the following program where clang gives different behavior for `#5` and `#6`. [Demo](https://godbolt.org/z/eno7n699f)

```c++
struct S {

template
constexpr operator T()&&
{
return 10;
}
constexpr operator int()const
{
return 4;
}

};

//static_assert( S{}==10); //#5 MSVC NO, Clang NO, GCC OK, EDG OK
static_assert(S{}.operator int() ==10); //#6 MSVC NO, Clang OK, GCC NO, EDG NO
```

I think both `#5` and `#6` should give same result.

Contributor guide

Open the contributing guide

Research direction

Start by compiling the linked Godbolt program and comparing the behavior of assertions #5 and #6 across Clang and the other listed compilers. Trace how Clang handles the conversion function in each expression; done means resolving the discrepancy so both forms produce the same result, consistent with the issue's expectation.

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
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.