We don't want the new call to get_dtor to cause function instantiation.
PR c++/107600
gcc/cp/ChangeLog:
* semantics.cc (trait_expr_value) [CPTK_HAS_TRIVIAL_DESTRUCTOR]:
Add cp_unevaluated.
gcc/testsuite/ChangeLog:
* g++.dg/ext/has_trivial_destructor-3.C: New test.
if (CLASS_TYPE_P (type1) && type_build_dtor_call (type1))
{
deferring_access_check_sentinel dacs (dk_no_check);
+ cp_unevaluated un;
tree fn = get_dtor (type1, tf_none);
if (!fn && !seen_error ())
warning (0, "checking %qs for type %qT with a destructor that "
--- /dev/null
+// { dg-do compile { target c++11 } }
+
+struct X;
+
+template<class T>
+struct default_delete
+{
+ void operator()(T*) { static_assert(sizeof(T), "type is not incomplete"); }
+};
+
+template<class T, class D = default_delete<T>>
+struct unique_ptr
+{
+ ~unique_ptr() { del(ptr); }
+
+ T* ptr;
+ D del;
+};
+
+
+constexpr bool b = __has_trivial_destructor(unique_ptr<X>);