<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - template friend is redefinition"
   href="https://bugs.llvm.org/show_bug.cgi?id=43400">43400</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>template friend is redefinition
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>Casey@Carter.net
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=22540" name="attach_22540" title="Repro">attachment 22540</a> <a href="attachment.cgi?id=22540&action=edit" title="Repro">[details]</a></span>
Repro

Compiling this well-formed program:

    template<class>
    constexpr bool is_lvalue_reference = false;
    template<class T>
    constexpr bool is_lvalue_reference<T&> = true;

    template<bool> struct int_if_ {};
    template<> struct int_if_<true> { using type = int; };
    template<bool B> using int_if = typename int_if_<B>::type;

    struct Derived;

    struct Base {
        template<class T>
        friend void operator|(T&, Derived const&) = delete;

        template<class T, int_if<!is_lvalue_reference<T>> = 0>
        friend T operator|(T&& t, Derived const&) {
            return static_cast<T&&>(t);
        }
    };

    struct Derived : Base {};

    int main() {
        struct vector {};
        vector v;
        v = static_cast<vector&&>(v) | Derived{};
    }

produces diagnostics:

    repro.cpp(15,17): error: redefinition of 'operator|'
        friend void operator|(T&, Derived const&) = delete;
                    ^
    repro.cpp(28,34): note: in instantiation of function template
specialization 'operator|<vector>' requested here
        v = static_cast<vector&&>(v) | Derived{};
                                     ^
    repro.cpp(15,17): note: previous definition is here
        friend void operator|(T&, Derived const&) = delete;
                    ^
    1 error generated.

The problem seems to reproduce on every version of Clang I try, with C++11 or
later.

This doesn't seem to be a duplicate of the other "friend redefinition" bugs
(#35012 and #41523), since it's a template friend of a non-template class, but
I could be mistaken.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>