[llvm-bugs] [Bug 35077] New: Incorrect overload resolution dependent on instantiation order

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Oct 25 11:45:43 PDT 2017


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

            Bug ID: 35077
           Summary: Incorrect overload resolution dependent on
                    instantiation order
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: kaballo86 at hotmail.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

Created attachment 19340
  --> https://bugs.llvm.org/attachment.cgi?id=19340&action=edit
include-less test case

In the following snippet, the result of overload resolution changes depending
on whether the template argument has been previously instantiated:

    #include <cstdio>
    #include <type_traits>
    using namespace std;

    template <typename ...Ts> struct foo {};

    template <typename T> struct is_foo : std::false_type {};
    template <typename ...Ts> struct is_foo<foo<Ts...>> : std::true_type {};

    ///
    template <typename ...Ts>
    void any_of(...) { 
      puts("true");
    }

    template <typename ...Ts>
    auto any_of(int) -> void_t<enable_if_t<!Ts::value>...> {
      puts("false");
    }

    // sizeof(is_foo<foo<>>); // uncomment-me
    any_of<is_foo<foo<>>>(0); // prints "false"

The result is "false", unless `is_foo<foo<>>` has been instantiated before in
the TU in which case the result is "true".

-- 
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/20171025/3cbc02b6/attachment.html>


More information about the llvm-bugs mailing list