https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86105
Bug ID: 86105 Summary: Conversion to ambiguous/inaccessible rvalue base is valid in unevaluated context Product: gcc Version: 8.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: johelegp at gmail dot com Target Milestone: --- In the following snippet, the assertions fail although the `static_cast` is ill-formed in non-unevaluated context. See https://godbolt.org/g/45VJvp, and a related Clang report https://bugs.llvm.org/show_bug.cgi?id=37691. ```C++ #include <utility> template <class To, class From> constexpr bool is_static_castable(...) { return false; }; template < class To, class From, class = decltype(static_cast<To>(std::declval<From>()))> constexpr bool is_static_castable(int) { return true; }; struct B { }; struct D : B { }; struct D2 : D , B { }; static_assert(!is_static_castable<B&&, D2&>(0), ""); struct D3 : private B { }; static_assert(!is_static_castable<B&&, D3&>(0), ""); void f() { D2 d2; (void)static_cast<B&&>(d2); D3 d3; (void)static_cast<B&&>(d3); } ```