gnu/gcc/4442e8b6cbffd113ec7bd25f449cc18f104f7150 libstdc++, testsuite: Implement C++26 P3450R1: Extend std::is_within_lifetime paper
Now that r17-4186 fixed constexpr evaluation of static_cast downcasts to diagnose
UB, this patch implements the C++26 P3450R1: Extend std::is_within_lifetime paper
purely in library by using __builtin_constant_p to verify if the static_cast
mandated by the standard is a constant expression.
2026-09-14 Jakub Jelinek <jakub@redhat.com>
libstdc++-v3/
* include/bits/version.def (within_lifetime): Change value from 202306
to 202603.
* include/bits/version.h: Regenerate.
* include/std/type_traits: Implement C++26 P3450R1: Extend
std::is_within_lifetime paper.
(std::is_within_lifetime): Add _Up template argument defaulted to void
and verify static_cast<const volatile _Up*>(__p) is a constant
expression.
gcc/testsuite/
* g++.dg/cpp26/within-lifetime1.C: Fix up C++26 paper number and name.
* g++.dg/cpp26/within-lifetime2.C: Likewise.
* g++.dg/cpp26/within-lifetime3.C: Likewise.
* g++.dg/cpp26/within-lifetime4.C: Likewise.
* g++.dg/cpp26/within-lifetime5.C: Likewise.
* g++.dg/cpp26/within-lifetime6.C: Likewise.
* g++.dg/cpp26/within-lifetime7.C: Likewise.
* g++.dg/cpp26/within-lifetime8.C: Likewise.
* g++.dg/cpp26/within-lifetime9.C: Likewise.
* g++.dg/cpp26/within-lifetime10.C: New test.
* g++.dg/cpp26/within-lifetime11.C: New test.
* g++.dg/cpp26/within-lifetime12.C: New test.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
15 files changed