[LLVMbugs] [Bug 12512] New: overload resolution incorrectly checking whether an implicit conversion sequence from initializer list to reference-to-array is viable

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Apr 9 17:40:12 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=12512

             Bug #: 12512
           Summary: overload resolution incorrectly checking whether an
                    implicit conversion sequence from initializer list to
                    reference-to-array is viable
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: compile-fail
          Severity: enhancement
          Priority: P
         Component: C++11
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: richard-llvm at metafoo.co.uk
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


g++ accepts this code, but Clang rejects it claiming there is an ambiguity:

int f(const int (&x)[3]) { return x[0] + x[1] + x[2]; }
int f(const int (&x)[2]) = delete;
int k = f({1, 2, 3});

The second 'f' should not be viable: there is no implicit conversion sequence
which converts {1, 2, 3} to const int (&)[2].

13.3.3.1.5/2 and 13.3.2/3 don't make it especially clear whether this should be
valid, but 13.3.2/3's requirement that "there shall exist for each argument an
implicit conversion sequence (13.3.3.1) that converts that argument to the
corresponding parameter of F" does not appear to be met: the conversion
sequence defined in 13.3.3.1.5/2 can't convert the argument to the right type.


[The related program:

int f(const int (&x)[2]);
int k = f({1, 2, 3});

is rejected, though strangely produces a note twice:

<stdin>:1:38: error: reference to type 'const int [2]' could not bind to an
rvalue of type 'int'
int f(const int (&x)[2]); int k = f({1, 2, 3});
                                     ^
<stdin>:1:19: note: passing argument to parameter 'x' here
int f(const int (&x)[2]); int k = f({1, 2, 3});
                  ^
<stdin>:1:19: note: passing argument to parameter 'x' here]

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list