<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 11/04/17 22:25, Richard Smith wrote:<br>
    </div>
    <blockquote
cite="mid:CAOfiQqkO3wu0dNpNtC5KhhNowEqE+Q6LsaSdgDP5i4rwHmrF6g@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_extra">
          <div class="gmail_quote">On 11 April 2017 at 08:35, Marshall
            Clow via Phabricator via cfe-commits <span dir="ltr"><<a
                moz-do-not-send="true"
                href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span>
            wrote:<br>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">mclow.lists
              added a comment.<br>
              <br>
              Complete reproducer:<br>
              <br>
              // Tested with with:  clang++ -std=c++14 -Wunused-function
              UnusedFVassily.cpp<br>
              //<br>
              // UnusedFVassily.cpp:8:39: warning: unused function
              '__test' [-Wunused-function]<br>
              //     template <class _Up> static __two
              __test(...);<br>
              //                                       ^<br>
              // UnusedFVassily.cpp:9:38: warning: unused function
              '__test' [-Wunused-function]<br>
              //     template <class _Up> static char
              __test(typename _Up::pointer* = 0);<br>
              //                                      ^<br>
              // 2 warnings generated.<br>
              <br>
              #include <type_traits><br>
              <br>
              namespace foo {<br>
              <span class=""><br>
                struct __two {char __lx; char __lxx;};<br>
                namespace __has_pointer_type_imp<br>
                {<br>
                <br>
              </span>  template <class _Up> static __two
              __test(...);<br>
                template <class _Up> static char __test(typename
              _Up::pointer* = 0);<br>
              <span class=""><br>
                }<br>
                <br>
                template <class _Tp><br>
                struct __has_pointer_type<br>
                <br>
              </span>  : public std::integral_constant<bool,
              sizeof(__has_pointer_type_imp:<wbr>:__test<_Tp>(0))
              == 1><br>
            </blockquote>
            <div><br>
            </div>
            <div>This is a bug in libc++. If this header is included
              into two translation units, they will be referencing
              different __test functions here (because the template has
              internal linkage due to the 'static'), resulting in an ODR
              violation.</div>
          </div>
        </div>
      </div>
    </blockquote>
    Richard, shall we warn on template definitions marked static? This
    would keep this pattern still working.<br>
    <blockquote
cite="mid:CAOfiQqkO3wu0dNpNtC5KhhNowEqE+Q6LsaSdgDP5i4rwHmrF6g@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_extra">
          <div class="gmail_quote">
            <div><br>
            </div>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <br>
              {<br>
              };<br>
              <br>
              }<br>
              <br>
              struct S1 {};<br>
              struct S2 { typedef void *pointer; };<br>
              <br>
              int main () {<br>
                      static_assert (!foo::__has_pointer_type<S1>:<wbr>:value,
              "" );<br>
                      static_assert (
              foo::__has_pointer_type<S2>::<wbr>value, "" );<br>
              <div class="HOEnZb">
                <div class="h5">}<br>
                  <br>
                  <br>
                  <a moz-do-not-send="true"
                    href="https://reviews.llvm.org/D29877"
                    rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D29877</a><br>
                  <br>
                  <br>
                  <br>
                  ______________________________<wbr>_________________<br>
                  cfe-commits mailing list<br>
                  <a moz-do-not-send="true"
                    href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
                  <a moz-do-not-send="true"
                    href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits"
                    rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
                </div>
              </div>
            </blockquote>
          </div>
          <br>
        </div>
      </div>
    </blockquote>
    <p><br>
    </p>
  </body>
</html>