[llvm-bugs] [Bug 36374] New: redifinition of friend function doesn't result in error

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Feb 13 15:20:05 PST 2018


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

            Bug ID: 36374
           Summary: redifinition of friend function doesn't result in
                    error
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: timshen91 at gmail.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

template <typename Derived>
struct A {
  friend Derived operator+(const Derived& a, const Derived& b) {
    return Derived(a, b);
  }
};

struct B : A<B> {
  B() = default;
  B(B, B) {}

  friend B operator+(const B& a, const B& b) { return B(a, b); }
};

void Foo() {
  B a, b, c = a + b;
  (void)c;
}


The example above should not compile, as there are two definitions for the
operator+.

-- 
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/20180213/3476a869/attachment.html>


More information about the llvm-bugs mailing list