[llvm-bugs] [Bug 49853] New: operator overload template that instantiates to `operator+(int, int)` during overload resolution incorrectly rejected

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Apr 5 22:31:53 PDT 2021


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

            Bug ID: 49853
           Summary: operator overload template that instantiates to
                    `operator+(int, int)` during overload resolution
                    incorrectly rejected
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: davidfromonline at gmail.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

The following valid translation unit

```
namespace foo {

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

struct s {};

void operator+(s, int);

template<typename T>
void operator+(typename indirect_int<T>::type, T);

void test() {
        s() + 1;
}

} // namespace foo
```

is rejected with the message

```
<source>:13:6: error: overloaded 'operator+' must have at least one parameter
of class or enumeration type
void operator+(typename indirect_int<T>::type, T);
     ^
<source>:16:6: note: in instantiation of function template specialization
'foo::operator+<int>' requested here
        s() + 1;
            ^
1 error generated.
Compiler returned: 1
```

See it live: https://godbolt.org/z/746nT6MYW

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210406/aa6fc210/attachment.html>


More information about the llvm-bugs mailing list