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

            Bug ID: 23342
           Summary: Warn when a template class declares a dependent friend
                    function [-Wnon-template-friend]
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    Classification: Unclassified

The out-of-line friend declaration is very likely broken because the
declaration is not part of the template. GCC has a -Wnon-template-friend
warning that finds this.

template <typename T>
struct Arg {
  friend bool operator==(const Arg& lhs, T rhs) {
    return false;
  }

  friend bool operator!=(const Arg& lhs, T rhs);
};
template <typename T>
bool operator!=(const Arg<T>& lhs, T rhs) {
  return true;
}
bool foo() {
  Arg<int> arg;
  return (arg == 42) || (arg != 42);
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to