Hi! https://eel.is/c++draft/class.prop#8.2 says that implicit lifetime class shall have at least one trivial eligible constructor. We currently walk all ctors and if it is default/copy/move ctor which is trivial and not deleted, return true, but as the following testcase shows, we should check also for unsatisfied constraints.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2026-06-29 Jakub Jelinek <[email protected]> PR c++/126007 * tree.cc (implicit_lifetime_type_p): Check if trivial default ctor, copy ctor or move ctor has satisfied constraints. * g++.dg/ext/is_implicit_lifetime3.C: New test. --- gcc/cp/tree.cc.jj 2026-06-25 10:03:50.818436378 +0200 +++ gcc/cp/tree.cc 2026-06-27 11:46:17.353081353 +0200 @@ -4955,6 +4955,7 @@ implicit_lifetime_type_p (tree t) fn = *iter; if ((default_ctor_p (fn) || copy_fn_p (fn) || move_fn_p (fn)) && trivial_fn_p (fn) + && constraints_satisfied_p (fn) && !DECL_DELETED_FN (fn)) return true; } --- gcc/testsuite/g++.dg/ext/is_implicit_lifetime3.C.jj 2026-06-27 11:49:33.102692105 +0200 +++ gcc/testsuite/g++.dg/ext/is_implicit_lifetime3.C 2026-06-27 11:50:38.106905466 +0200 @@ -0,0 +1,11 @@ +// PR c++/126007 +// { dg-do compile { target c++20 } } + +template <bool B> +struct S { + S () requires B = default; + S (const S &) {} +}; + +static_assert (!__builtin_is_implicit_lifetime (S<false>)); +static_assert (__builtin_is_implicit_lifetime (S<true>)); Jakub
