[llvm-bugs] [Bug 43454] New: Hard error when checking validity of protected default constructor in SFINAE context
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Sep 25 13:44:13 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=43454
Bug ID: 43454
Summary: Hard error when checking validity of protected default
constructor in SFINAE context
Product: clang
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Frontend
Assignee: unassignedclangbugs at nondot.org
Reporter: ldionne at apple.com
CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
richard-llvm at metafoo.co.uk
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: https://godbolt.org/z/e9-G8b
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.
--
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/20190925/568f1a0f/attachment.html>
More information about the llvm-bugs
mailing list