https://bugs.llvm.org/show_bug.cgi?id=51291

            Bug ID: 51291
           Summary: Wrong program output in case of many concept
                    conversion operators
           Product: clang
           Version: 12.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangb...@nondot.org
          Reporter: fchelno...@gmail.com
                CC: blitzrak...@gmail.com, dgre...@apple.com,
                    erik.pilking...@gmail.com, llvm-bugs@lists.llvm.org,
                    richard-l...@metafoo.co.uk

Example code:
```
template <auto =[]{}> class C;
template <typename, typename = C<>> concept x = true;

#include <iostream>

struct S {
    operator x<C<>> auto() { return 42; }
    operator x<C<>> auto() { return '+'; }
    operator x<C<>> auto() { return 44LL; }
    operator x<C<>> auto() { return 45.5; }
    operator x<C<>> auto() { return 46.5f; }
    operator x<C<>> auto() { return 47L; }    
    operator x<C<>> auto() { return 48ULL; }
    operator x<C<>> auto() { return 49U; }
};

int main() {
    S s;
    std::cout << (int)s << "\n";
    std::cout << (char)s << "\n";
    std::cout << (long long)s << "\n";

    std::cout << (double)s << "\n";
    std::cout << (float)s << "\n";
    std::cout << (long)s << "\n";

    std::cout << (unsigned long long)s << "\n";
    std::cout << (unsigned)s << "\n";
}
```

Clang prints here:
```
49
1
49
0
0
49
49
49
```
which is obviously wrong.

Demo: https://gcc.godbolt.org/z/dPa4GxYhc

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to