<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 - Hard error when checking validity of protected default constructor in SFINAE context"
   href="https://bugs.llvm.org/show_bug.cgi?id=43454">43454</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Hard error when checking validity of protected default constructor in SFINAE context
          </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>All
          </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>Frontend
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>ldionne@apple.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The following code causes a hard compilation error on Clang trunk in all
standard modes, except C++17:

    #include <utility>
    #include <type_traits>

    struct Base { };
    struct Derived : Base { protected: Derived() = default; };


    template <class _Tp>
    void test_implicit_default_constructible(_Tp);

    template <class _Tp, class = void>
    struct is_implicitly_default_constructible
        : std::false_type
    { };

    template <class _Tp>
    struct is_implicitly_default_constructible<_Tp,
decltype(test_implicit_default_constructible<_Tp const&>({}))>
        : std::is_default_constructible<_Tp>
    { };
    static_assert(!is_implicitly_default_constructible<Derived>::value, "");

You can reproduce with:

    $ cat <file above> | clang++ -xc++ - -std=c++2a -fsyntax-only

    <stdin>:17:110: error: calling a protected constructor of class 'Derived'
        struct is_implicitly_default_constructible<_Tp,
decltype(test_implicit_default_constructible<_Tp const&>({}))>
                                                                               
                                 ^
    <stdin>:20:20: note: in instantiation of template class
'is_implicitly_default_constructible<Derived, void>' requested
          here
        static_assert(!is_implicitly_default_constructible<Derived>::value,
"");
                       ^
    <stdin>:5:40: note: declared protected here
        struct Derived : Base { protected: Derived() = default; };
                                           ^
    1 error generated.

Live repro: <a href="https://godbolt.org/z/e9-G8b">https://godbolt.org/z/e9-G8b</a>


Instead, I would expect the static_assert to pass since Derived isn't default
constructible (because of access checking), and we check that inside a SFINAE
context (so no hard error should happen).

Note that Clang produces an error in C++14 and C++2a modes, but produces no
error in C++17 mode. GCC trunk, in comparison, produces no error in C++14,
C++17 and C++2a mode.</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>