Bug 119060 - [C++26] P1494R5/P3641R0 - Partial program correctness
Summary: [C++26] P1494R5/P3641R0 - Partial program correctness
Status: ASSIGNED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 15.0
: P3 normal
Target Milestone: ---
Assignee: Iain Sandoe
URL: https://gcc.gnu.org/pipermail/gcc-pat...
Keywords:
Depends on:
Blocks: c++26-core
  Show dependency treegraph
 
Reported: 2025-02-28 14:53 UTC by Jakub Jelinek
Modified: 2025-10-18 22:19 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2025-02-28 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Jelinek 2025-02-28 14:53:14 UTC
See <https://wg21.link/P1494R5>.
Comment 1 Drea Pinski 2025-03-01 00:20:40 UTC
Note I think R4 is the only version that is public so far.
Comment 2 Iain Sandoe 2025-03-04 22:28:15 UTC
I have a patch for the language side of this which has been in use on the contracts branch for a while.
Comment 3 Iain Sandoe 2025-09-02 16:53:31 UTC
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?
Comment 4 Iain Sandoe 2025-09-04 17:04:21 UTC
patches posted.
Comment 5 GCC Commits 2025-10-18 22:17:56 UTC
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>
Comment 6 GCC Commits 2025-10-18 22:18:16 UTC
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>
Comment 7 Iain Sandoe 2025-10-18 22:19:35 UTC
leaving this open while we discuss what, if anything, might need to be added to the RTL lowering.