[llvm-bugs] [Bug 47704] New: Overloading resolved to pointer argument instead of initializer_list

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Oct 1 09:38:26 PDT 2020


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

            Bug ID: 47704
           Summary: Overloading resolved to pointer argument instead of
                    initializer_list
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: chfast 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

For the following C++11 code:

#include <initializer_list>

struct V
{
    V(int) {}
};

inline int f(void*) { return 1; }

inline int f(std::initializer_list<V>) { return 2; }

int invoke_test() { return f({0}); }


The function f invocation f({0}) is resolved to f(void*).
GCC does the opposite.
I believe it should be initializer_list because {} is used.
We also get the -Wbraced-scalar-init warning.

warning: braces around scalar initializer [-Wbraced-scalar-init]

int invoke_test() { return f({0}); }

                             ^~~

https://godbolt.org/z/qj5voh

-- 
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/20201001/ac8813a3/attachment.html>


More information about the llvm-bugs mailing list