[llvm-bugs] [Bug 42318] New: Overload resolution and enum promotion

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jun 19 03:05:46 PDT 2019


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

            Bug ID: 42318
           Summary: Overload resolution and enum promotion
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: jenda.tusil 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

Clang incorrectly rejects the following program, saying "call to 'bar' is
ambiguous":

```
enum E : short {
        Foo = 1
};

int bar(int) { return 1; }
int bar(short) { return 0; }

int main() {
        return bar(Foo);
}
```

According to [over.ics.rank/4.2](http://eel.is/c++draft/over.ics.rank#4.2), the
`int bar(short)` overload is a better match:

> A conversion that promotes an enumeration whose underlying type is fixed to its underlying type is better than one that promotes to the promoted underlying type, if the two are different.

The bug manifest itself in various versions of clang, including the trunk.

-- 
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/20190619/abcd6414/attachment.html>


More information about the llvm-bugs mailing list