https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126442

            Bug ID: 126442
           Summary: binary operator deduction fails to match SFINAE
                    conversion function
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: phiren at gmail dot com
  Target Milestone: ---

Minimal-ish reproduction:

```
template<typename> struct is_int {};
template<> struct is_int<int> { using type = int; };

struct T {
    template<typename U, typename = typename is_int<U>::type>
    operator U() { return {}; }
};

int main ()
{
    T a;
    0+a; // error: no match for 'operator+' (operand types are 'int' and 'T')
    a+a; // error: no match for 'operator+' (operand types are 'T' and 'T')
}
```

As far as I can tell, there is nothing in the c++ spec saying this shouldn't
work. 
The first `0+a` expression actually works in clang (but not the second)

Both expressions failed in every single gcc/msvc version I checked on godbolt,
all the from latest trunk all the way back to gcc 5

Reply via email to