See <https://wg21.link/P1494R5>.
Note I think R4 is the only version that is public so far.
I have a patch for the language side of this which has been in use on the contracts branch for a while.
I think we should just add P3641 to this BZ, since it's just changing the name - the functionality is the same. I have a patch for P1494 that has the old name, so will update that to the revised one and post. any objections to considering the two papers together?
patches posted.
The master branch has been updated by Iain D Sandoe <iains@gcc.gnu.org>: https://gcc.gnu.org/g:9056b5faa87df59fb8eb2f92096a8e6e7d246757 commit r16-4485-g9056b5faa87df59fb8eb2f92096a8e6e7d246757 Author: Iain Sandoe <iain@sandoe.co.uk> Date: Sat Sep 6 17:11:21 2025 +0100 c++: Implement P1494 and P3641 Partial program correctness [PR119060]. P1494 provides a mechanism that serves to demarc epochs within the code preventing UB-based optimisations from 'time traveling' across such boundaries. The additional paper, P3641, alters the name of the function to 'observable_checkpoint' which is the name used here. This implementation maintains the observable function call through to expand, where it produces no code. PR c++/119060 gcc/ChangeLog: * builtins.cc (expand_builtin): Handle BUILT_IN_OBSERVABLE_CHKPT. * builtins.def (BUILT_IN_OBSERVABLE_CHKPT): New. * tree.cc (build_common_builtin_nodes): Build observable checkpoint builtin. gcc/cp/ChangeLog: * cxxapi-data.csv: Add observable_checkpoint to <utility>. * std-name-hint.gperf: Add observable_checkpoint to <utility>. * std-name-hint.h: Regenerate. gcc/testsuite/ChangeLog: * g++.dg/cpp26/observable-checkpoint.C: New test. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
The master branch has been updated by Iain D Sandoe <iains@gcc.gnu.org>: https://gcc.gnu.org/g:1e84849cb2a1d777b38b45dab8c6e5ecd49b6b77 commit r16-4486-g1e84849cb2a1d777b38b45dab8c6e5ecd49b6b77 Author: Iain Sandoe <iain@sandoe.co.uk> Date: Thu Sep 4 16:21:16 2025 +0100 libstdc++: Implement P1494 and P3641 Partial program correctness [PR119060] This implements the library parts of P1494 as amended by P3641. For GCC the compiler itself treats stdio operations as equivalent to the observable checkpoint and thus it does not appear to be necessary to add calls to those functions (it will not alter the outcome). This adds the facility for C++26, although there is no reason, in principle, that it would not work back to C++11 at least. PR c++/119060 libstdc++-v3/ChangeLog: * include/bits/version.def: Add observable_checkpoint at present allowed from C++26. * include/bits/version.h: Regenerate. * include/std/utility: Add std::observable_checkpoint(). * src/c++23/std.cc.in: Add obervable_checkpoint () to utility. Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
leaving this open while we discuss what, if anything, might need to be added to the RTL lowering.