[llvm-bugs] [Bug 40098] New: Incorrect (ambiguous) overload resolution when converting initializer list to array
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Dec 19 03:37:46 PST 2018
https://bugs.llvm.org/show_bug.cgi?id=40098
Bug ID: 40098
Summary: Incorrect (ambiguous) overload resolution when
converting initializer list to array
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: miyuki-llvm at miyuki.ru
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
Consider the following code:
struct S {
S(int i=1) {}
} s1, s2;
int f(S (&&r)[2]) { return 100; }
int f(S (&&r)[3]) { return 200; }
int main() {
int g = f({s1, s2});
// assert(g == 100);
}
According to [over.ics.rank]/3.1.2:
"List-initialization sequence L1 is a better conversion sequence than
list-initialization sequence L2 if:
- ...
- L1 converts to type “array of N1 T”, L2 converts to type “array of N2 T”, and
N1 is smaller than N2"
I.e., the correct behaviour is to call the first overload. Instead Clang
rejects the code because it considers the call ambiguous.
--
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/20181219/4de64dd7/attachment.html>
More information about the llvm-bugs
mailing list