This patch (with the original shorter name) has been in use on the contracts
development branch for almost a year, and has been tested in isolation on
x86_64-darwin and powerpc64le-linux.
OK for trunk?
thanks
Iain

--- 8< ---

The paper provides a mechanism that serves to demarc epochs within the code
preventing UB-based optimisations from 'time traveling' across such
boundaries.  The additional paper 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 zero code). As such it does not alter handling
of RTL.

        PR c++/119060

gcc/ChangeLog:

        * builtins.cc (expand_builtin): Handle BUILT_IN_OBSERVABLE_CHKPT.
        * builtins.def (BUILT_IN_OBSERVABLE_CHKPT): New.

gcc/c-family/ChangeLog:

        * c-common.cc: Add __builtin_observable_checkpoint.
        * c-common.h (enum rid): Add RID_BUILTIN_OBSERVABLE_CHKPT.

gcc/cp/ChangeLog:

        * cp-objcp-common.cc (names_builtin_p): Handle
        BUILT_IN_OBSERVABLE_CHKPT.
        * cxxapi-data.csv: Add observable_checkpoint to <utility>.
        * parser.cc (cp_parser_postfix_expression): Handle
        __builtin_observable_checkpoint.
        * 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 <i...@sandoe.co.uk>
---
 gcc/builtins.cc                               |   4 +
 gcc/builtins.def                              |   1 +
 gcc/c-family/c-common.cc                      |   1 +
 gcc/c-family/c-common.h                       |   1 +
 gcc/cp/cp-objcp-common.cc                     |   1 +
 gcc/cp/cxxapi-data.csv                        |   1 +
 gcc/cp/parser.cc                              |  17 +++
 gcc/cp/std-name-hint.gperf                    |   1 +
 gcc/cp/std-name-hint.h                        | 142 +++++++++---------
 .../g++.dg/cpp26/observable-checkpoint.C      |  24 +++
 10 files changed, 123 insertions(+), 70 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp26/observable-checkpoint.C

diff --git a/gcc/builtins.cc b/gcc/builtins.cc
index ced84781afa..06a70decebf 100644
--- a/gcc/builtins.cc
+++ b/gcc/builtins.cc
@@ -8418,6 +8418,10 @@ expand_builtin (tree exp, rtx target, rtx subtarget, 
machine_mode mode,
       expand_builtin_unreachable ();
       return const0_rtx;
 
+    case BUILT_IN_OBSERVABLE_CHKPT:
+      /* Emits no code.  */
+      return const0_rtx;
+
     CASE_FLT_FN (BUILT_IN_SIGNBIT):
     case BUILT_IN_SIGNBITD32:
     case BUILT_IN_SIGNBITD64:
diff --git a/gcc/builtins.def b/gcc/builtins.def
index 3dc2333c6f2..7cd5353bcb1 100644
--- a/gcc/builtins.def
+++ b/gcc/builtins.def
@@ -1142,6 +1142,7 @@ DEF_C2Y_BUILTIN        (BUILT_IN_ULABS, "ulabs", 
BT_FN_ULONG_LONG, ATTR_CONST_NO
 DEF_C2Y_BUILTIN        (BUILT_IN_ULLABS, "ullabs", BT_FN_ULONGLONG_LONGLONG, 
ATTR_CONST_NOTHROW_LEAF_LIST)
 DEF_GCC_BUILTIN        (BUILT_IN_UNREACHABLE_TRAP, "unreachable trap", 
BT_FN_VOID, ATTR_CONST_NORETURN_NOTHROW_LEAF_COLD_LIST)
 DEF_GCC_BUILTIN        (BUILT_IN_UNREACHABLE, "unreachable", BT_FN_VOID, 
ATTR_CONST_NORETURN_NOTHROW_LEAF_COLD_LIST)
+DEF_GCC_BUILTIN        (BUILT_IN_OBSERVABLE_CHKPT, "observable_checkpoint", 
BT_FN_VOID, ATTR_NOTHROW_LEAF_LIST)
 DEF_GCC_BUILTIN        (BUILT_IN_UNWIND_INIT, "unwind_init", BT_FN_VOID, 
ATTR_NULL)
 DEF_GCC_BUILTIN        (BUILT_IN_UPDATE_SETJMP_BUF, "update_setjmp_buf", 
BT_FN_VOID_PTR, ATTR_NULL)
 DEF_GCC_BUILTIN        (BUILT_IN_VA_COPY, "va_copy", 
BT_FN_VOID_VALIST_REF_VALIST_ARG, ATTR_NOTHROW_LEAF_LIST)
diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc
index e7dd4602ac1..62eef89acfa 100644
--- a/gcc/c-family/c-common.cc
+++ b/gcc/c-family/c-common.cc
@@ -441,6 +441,7 @@ const struct c_common_resword c_common_reswords[] =
   { "__builtin_launder", RID_BUILTIN_LAUNDER, D_CXXONLY },
   { "__builtin_operator_new", RID_BUILTIN_OPERATOR_NEW, D_CXXONLY },
   { "__builtin_operator_delete", RID_BUILTIN_OPERATOR_DELETE, D_CXXONLY },
+  { "__builtin_observable_checkpoint", RID_BUILTIN_OBSERVABLE_CHKPT, D_CXXONLY 
},
   { "__builtin_shuffle", RID_BUILTIN_SHUFFLE, 0 },
   { "__builtin_shufflevector", RID_BUILTIN_SHUFFLEVECTOR, 0 },
   { "__builtin_stdc_bit_ceil", RID_BUILTIN_STDC, D_CONLY },
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index b6021d24173..7f73b762ab6 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -168,6 +168,7 @@ enum rid
   /* C++ extensions */
   RID_ADDRESSOF,
   RID_BUILTIN_LAUNDER,
+  RID_BUILTIN_OBSERVABLE_CHKPT,
   RID_BUILTIN_BIT_CAST,
   RID_BUILTIN_OPERATOR_NEW, RID_BUILTIN_OPERATOR_DELETE,
 
diff --git a/gcc/cp/cp-objcp-common.cc b/gcc/cp/cp-objcp-common.cc
index ee1c0ba3de3..19d55686fbb 100644
--- a/gcc/cp/cp-objcp-common.cc
+++ b/gcc/cp/cp-objcp-common.cc
@@ -584,6 +584,7 @@ names_builtin_p (const char *name)
     case RID_BUILTIN_SHUFFLE:
     case RID_BUILTIN_SHUFFLEVECTOR:
     case RID_BUILTIN_LAUNDER:
+    case RID_BUILTIN_OBSERVABLE_CHKPT:
     case RID_BUILTIN_ASSOC_BARRIER:
     case RID_BUILTIN_BIT_CAST:
     case RID_OFFSETOF:
diff --git a/gcc/cp/cxxapi-data.csv b/gcc/cp/cxxapi-data.csv
index 41f75b0092d..074368f1573 100644
--- a/gcc/cp/cxxapi-data.csv
+++ b/gcc/cp/cxxapi-data.csv
@@ -952,6 +952,7 @@
 <utility>,in_range,1,cxx20
 <utility>,to_underlying,1,cxx23
 <utility>,unreachable,1,cxx23
+<utility>,observable_checkpoint,1,cxx26
 <utility>,integer_sequence,1,cxx14
 <utility>,index_sequence,1,cxx14
 <utility>,make_integer_sequence,1,cxx14
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index 9f9bd565004..ee51b075860 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -8017,6 +8017,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool 
address_p, bool cast_p,
     case RID_BUILTIN_SHUFFLE:
     case RID_BUILTIN_SHUFFLEVECTOR:
     case RID_BUILTIN_LAUNDER:
+    case RID_BUILTIN_OBSERVABLE_CHKPT:
     case RID_BUILTIN_ASSOC_BARRIER:
     case RID_BUILTIN_OPERATOR_NEW:
     case RID_BUILTIN_OPERATOR_DELETE:
@@ -8062,6 +8063,22 @@ cp_parser_postfix_expression (cp_parser *parser, bool 
address_p, bool cast_p,
              }
            break;
 
+         case RID_BUILTIN_OBSERVABLE_CHKPT:
+           if (vec->length () == 0)
+             {
+               tree fn = builtin_decl_explicit (BUILT_IN_OBSERVABLE_CHKPT);
+               releasing_vec vec;
+               postfix_expression = finish_call_expr (fn, &vec, false, false,
+                                                      tf_warning_or_error);
+             }
+           else
+             {
+               error_at (loc, "%<__builtin_observable_checkpoint%> does not"
+                         " take arguments");
+               postfix_expression = error_mark_node;
+             }
+           break;
+
          case RID_BUILTIN_ASSOC_BARRIER:
            if (vec->length () == 1)
              postfix_expression = build1_loc (loc, PAREN_EXPR,
diff --git a/gcc/cp/std-name-hint.gperf b/gcc/cp/std-name-hint.gperf
index 8ff08c0fa7c..3e06e61501d 100644
--- a/gcc/cp/std-name-hint.gperf
+++ b/gcc/cp/std-name-hint.gperf
@@ -577,6 +577,7 @@ piecewise_construct, "<utility>", cxx11
 piecewise_construct_t, "<utility>", cxx11
 to_underlying, "<utility>", cxx23
 unreachable, "<utility>", cxx23
+observable_checkpoint, "<utility>", cxx26
 # <variant>
 bad_variant_access, "<variant>", cxx17
 holds_alternative, "<variant>", cxx17
diff --git a/gcc/cp/std-name-hint.h b/gcc/cp/std-name-hint.h
index c5f800400ea..e354032a229 100644
--- a/gcc/cp/std-name-hint.h
+++ b/gcc/cp/std-name-hint.h
@@ -135,7 +135,7 @@ std_name_hint_lookup::find (const char *str, size_t len)
 {
   enum
     {
-      TOTAL_KEYWORDS = 487,
+      TOTAL_KEYWORDS = 488,
       MIN_WORD_LENGTH = 2,
       MAX_WORD_LENGTH = 39,
       MIN_HASH_VALUE = 7,
@@ -178,7 +178,7 @@ std_name_hint_lookup::find (const char *str, size_t len)
       {"print", "<print>", cxx23},
 #line 221 "std-name-hint.gperf"
       {"promise", "<future>", cxx11},
-#line 581 "std-name-hint.gperf"
+#line 582 "std-name-hint.gperf"
       {"bad_variant_access", "<variant>", cxx17},
 #line 328 "std-name-hint.gperf"
       {"to_address", "<memory>", cxx20},
@@ -198,7 +198,7 @@ std_name_hint_lookup::find (const char *str, size_t len)
       {"nounitbuf", "<ios>", cxx98},
 #line 433 "std-name-hint.gperf"
       {"basic_stringbuf", "<sstream>", cxx98},
-#line 592 "std-name-hint.gperf"
+#line 593 "std-name-hint.gperf"
       {"vector", "<vector>", cxx98},
 #line 246 "std-name-hint.gperf"
       {"noshowbase", "<ios>", cxx98},
@@ -228,7 +228,7 @@ std_name_hint_lookup::find (const char *str, size_t len)
       {"tuple_element", "<tuple>", cxx11},
 #line 519 "std-name-hint.gperf"
       {"tuple_element_t", "<tuple>", cxx14},
-#line 584 "std-name-hint.gperf"
+#line 585 "std-name-hint.gperf"
       {"variant", "<variant>", cxx17},
 #line 386 "std-name-hint.gperf"
       {"ends", "<ostream>", cxx98},
@@ -244,11 +244,11 @@ std_name_hint_lookup::find (const char *str, size_t len)
       {"noshowpos", "<ios>", cxx98},
 #line 388 "std-name-hint.gperf"
       {"flush_emit", "<ostream>", cxx20},
-#line 585 "std-name-hint.gperf"
+#line 586 "std-name-hint.gperf"
       {"variant_alternative", "<variant>", cxx17},
 #line 537 "std-name-hint.gperf"
       {"void_t", "<type_traits>", cxx17},
-#line 586 "std-name-hint.gperf"
+#line 587 "std-name-hint.gperf"
       {"variant_alternative_t", "<variant>", cxx17},
 #line 134 "std-name-hint.gperf"
       {"relation", "<concepts>", cxx20},
@@ -338,7 +338,7 @@ std_name_hint_lookup::find (const char *str, size_t len)
       {"basic_streambuf", "<streambuf>", cxx98},
 #line 167 "std-name-hint.gperf"
       {"basic_format_args", "<format>", cxx20},
-#line 588 "std-name-hint.gperf"
+#line 589 "std-name-hint.gperf"
       {"variant_size", "<variant>", cxx17},
 #line 407 "std-name-hint.gperf"
       {"multiset", "<set>", cxx98},
@@ -360,13 +360,13 @@ std_name_hint_lookup::find (const char *str, size_t len)
       {"remove_cvref_t", "<type_traits>", cxx20},
 #line 289 "std-name-hint.gperf"
       {"ostream_iterator", "<iterator>", cxx98},
-#line 587 "std-name-hint.gperf"
+#line 588 "std-name-hint.gperf"
       {"variant_npos", "<variant>", cxx17},
 #line 244 "std-name-hint.gperf"
       {"left", "<ios>", cxx98},
 #line 200 "std-name-hint.gperf"
       {"fstream", "<fstream>", cxx98},
-#line 590 "std-name-hint.gperf"
+#line 591 "std-name-hint.gperf"
       {"visit", "<variant>", cxx17},
 #line 208 "std-name-hint.gperf"
       {"invoke", "<functional>", cxx17},
@@ -458,7 +458,7 @@ std_name_hint_lookup::find (const char *str, size_t len)
       {"showpoint", "<ios>", cxx98},
 #line 446 "std-name-hint.gperf"
       {"stacktrace", "<stacktrace>", cxx23},
-#line 589 "std-name-hint.gperf"
+#line 590 "std-name-hint.gperf"
       {"variant_size_v", "<variant>", cxx17},
 #line 212 "std-name-hint.gperf"
       {"reference_wrapper", "<functional>", cxx11},
@@ -474,7 +474,7 @@ std_name_hint_lookup::find (const char *str, size_t len)
       {"allocator_traits", "<memory>", cxx11},
 #line 183 "std-name-hint.gperf"
       {"make_wformat_args", "<format>", cxx20},
-#line 583 "std-name-hint.gperf"
+#line 584 "std-name-hint.gperf"
       {"monostate", "<variant>", cxx17},
 #line 387 "std-name-hint.gperf"
       {"flush", "<ostream>", cxx98},
@@ -582,7 +582,7 @@ std_name_hint_lookup::find (const char *str, size_t len)
       {"stop_source", "<stop_token>", cxx20},
 #line 548 "std-name-hint.gperf"
       {"unordered_set", "<unordered_set>", cxx11},
-#line 582 "std-name-hint.gperf"
+#line 583 "std-name-hint.gperf"
       {"holds_alternative", "<variant>", cxx17},
 #line 514 "std-name-hint.gperf"
       {"make_tuple", "<tuple>", cxx11},
@@ -960,6 +960,8 @@ std_name_hint_lookup::find (const char *str, size_t len)
       {"domain_error", "<stdexcept>", cxx98},
 #line 84 "std-name-hint.gperf"
       {"chrono::steady_clock", "<chrono>", cxx11},
+#line 580 "std-name-hint.gperf"
+      {"observable_checkpoint", "<utility>", cxx26},
 #line 188 "std-name-hint.gperf"
       {"vformat_to", "<format>", cxx20},
 #line 54 "std-name-hint.gperf"
@@ -1142,7 +1144,7 @@ std_name_hint_lookup::find (const char *str, size_t len)
          -1,    -1,    24,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    25,    26,    27,    -1,
          -1,    -1,    28,    29,    -1,    -1,    30,
-       -629,  -456,    -2,    33,    -1,    34,    -1,
+       -630,  -457,    -2,    33,    -1,    34,    -1,
          35,    -1,    36,    -1,    -1,    -1,    -1,
          37,    -1,    38,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    39,    -1,    -1,    -1,
@@ -1184,8 +1186,8 @@ std_name_hint_lookup::find (const char *str, size_t len)
          -1,   152,   153,    -1,    -1,    -1,    -1,
          -1,    -1,   154,    -1,   155,   156,    -1,
          -1,    -1,   157,    -1,    -1,   158,    -1,
-        159,   160,    -1,    -1,    -1,  -933,    -1,
-        163,   164,    -1,   165,  -326,    -2,    -1,
+        159,   160,    -1,    -1,    -1,  -934,    -1,
+        163,   164,    -1,   165,  -327,    -2,    -1,
          -1,   166,    -1,    -1,    -1,    -1,   167,
         168,    -1,   169,    -1,    -1,    -1,   170,
         171,   172,   173,    -1,    -1,    -1,   174,
@@ -1195,11 +1197,11 @@ std_name_hint_lookup::find (const char *str, size_t len)
          -1,   185,    -1,   186,   187,    -1,   188,
         189,   190,   191,   192,    -1,   193,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
-         -1,    -1,    -1,   194,    -1, -1005,  -292,
+         -1,    -1,    -1,   194,    -1, -1006,  -293,
          -2,    -1,    -1,    -1,   197,    -1,    -1,
         198,   199,   200,   201,    -1,    -1,    -1,
         202,   203,    -1,    -1,    -1,    -1,   204,
-         -1,    -1, -1030,  -282,    -2,    -1,   207,
+         -1,    -1, -1031,  -283,    -2,    -1,   207,
          -1,    -1,    -1,   208,   209,    -1,    -1,
          -1,   210,    -1,    -1,    -1,   211,    -1,
         212,    -1,    -1,   213,    -1,    -1,   214,
@@ -1227,7 +1229,7 @@ std_name_hint_lookup::find (const char *str, size_t len)
         275,   276,    -1,   277,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,   278,    -1,
          -1,    -1,    -1,    -1,   279,   280,   281,
-      -1225,   284,  -205,    -2,    -1,    -1,    -1,
+      -1226,   284,  -206,    -2,    -1,    -1,    -1,
          -1,   285,    -1,    -1,    -1,    -1,   286,
         287,   288,    -1,    -1,   289,   290,   291,
          -1,    -1,    -1,    -1,   292,    -1,    -1,
@@ -1247,7 +1249,7 @@ std_name_hint_lookup::find (const char *str, size_t len)
          -1,    -1,   331,    -1,   332,    -1,    -1,
          -1,    -1,   333,   334,   335,    -1,    -1,
          -1,   336,    -1,    -1,   337,   338,    -1,
-         -1,    -1,    -1, -1367,  -148,    -2,    -1,
+         -1,    -1,    -1, -1368,  -149,    -2,    -1,
         341,    -1,    -1,    -1,    -1,    -1,    -1,
         342,    -1,    -1,   343,    -1,    -1,    -1,
          -1,   344,   345,    -1,   346,    -1,    -1,
@@ -1282,70 +1284,70 @@ std_name_hint_lookup::find (const char *str, size_t len)
          -1,    -1,    -1,    -1,    -1,    -1,   395,
         396,   397,    -1,    -1,   398,   399,    -1,
         400,   401,   402,   403,   404,   405,   406,
-        407,    -1,   408,    -1,    -1,   409,   410,
-         -1,    -1,    -1,   411,    -1,    -1,    -1,
-         -1,   412,    -1,   413,    -1,    -1,   414,
+        407,   408,   409,    -1,    -1,   410,   411,
+         -1,    -1,    -1,   412,    -1,    -1,    -1,
+         -1,   413,    -1,   414,    -1,    -1,   415,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
-         -1,   415,    -1,    -1,    -1,   416,    -1,
+         -1,   416,    -1,    -1,    -1,   417,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
-        417,    -1,    -1,   418,    -1,    -1,   419,
+        418,    -1,    -1,   419,    -1,    -1,   420,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
-         -1,    -1,    -1,   420,   421,    -1,    -1,
-         -1,    -1,    -1,    -1,   422,    -1,    -1,
+         -1,    -1,    -1,   421,   422,    -1,    -1,
          -1,    -1,    -1,    -1,   423,    -1,    -1,
-         -1,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,   424,    -1,    -1,
-         -1,    -1,    -1,    -1, -1704,   -62,    -2,
-         -1,    -1,    -1,    -1,   427,    -1,    -1,
-         -1,    -1,    -1,   428,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
-         -1,    -1,    -1,    -1,   429,    -1,    -1,
+         -1,    -1,    -1,    -1,   425,    -1,    -1,
+         -1,    -1,    -1,    -1, -1705,   -62,    -2,
+         -1,    -1,    -1,    -1,   428,    -1,    -1,
+         -1,    -1,    -1,   429,    -1,    -1,    -1,
+         -1,    -1,    -1,    -1,    -1,    -1,    -1,
+         -1,    -1,    -1,    -1,   430,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
-        430,    -1,    -1,    -1,    -1,    -1,   431,
-         -1,    -1,    -1,    -1,   432,    -1,    -1,
-         -1,    -1,    -1,    -1,    -1,   433,    -1,
-         -1,    -1,    -1,   434,    -1,    -1,   435,
-         -1,    -1,    -1,    -1,    -1,    -1,   436,
-        437,    -1,    -1,   438,    -1,    -1,    -1,
-         -1,    -1,   439,   440,    -1,    -1,    -1,
-        441,    -1,   442,    -1,   443,    -1,    -1,
-        444,    -1,    -1,    -1,   445,    -1,    -1,
+        431,    -1,    -1,    -1,    -1,    -1,   432,
+         -1,    -1,    -1,    -1,   433,    -1,    -1,
+         -1,    -1,    -1,    -1,    -1,   434,    -1,
+         -1,    -1,    -1,   435,    -1,    -1,   436,
+         -1,    -1,    -1,    -1,    -1,    -1,   437,
+        438,    -1,    -1,   439,    -1,    -1,    -1,
+         -1,    -1,   440,   441,    -1,    -1,    -1,
+        442,    -1,   443,    -1,   444,    -1,    -1,
+        445,    -1,    -1,    -1,   446,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
-         -1,    -1,    -1,    -1,    -1,    -1,   446,
-         -1,   447,    -1,    -1,    -1,    -1,    -1,
-        448,    -1,    -1,    -1,    -1,    -1,    -1,
+         -1,    -1,    -1,    -1,    -1,    -1,   447,
+         -1,   448,    -1,    -1,    -1,    -1,    -1,
+        449,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
-         -1,    -1,    -1,   449,    -1,   450,    -1,
-         -1,    -1,    -1,    -1,   451,    -1,    -1,
-         -1,    -1,    -1,   452,    -1,    -1,    -1,
-         -1,    -1,   453,    -1,    -1,   454,    -1,
+         -1,    -1,    -1,   450,    -1,   451,    -1,
+         -1,    -1,    -1,    -1,   452,    -1,    -1,
+         -1,    -1,    -1,   453,    -1,    -1,    -1,
+         -1,    -1,   454,    -1,    -1,   455,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
-         -1,   455,    -1,    -1,    -1,   456,    -1,
+         -1,   456,    -1,    -1,    -1,   457,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
-         -1,    -1,    -1,   457,    -1,   458,   459,
-         -1,    -1,    -1,    -1,    -1,    -1,   460,
-         -1,    -1,    -1,    -1,   461,    -1,    -1,
-         -1,    -1,   462,    -1,    -1,    -1,    -1,
-         -1,    -1,    -1,    -1,   463,    -1,    -1,
-         -1,    -1,    -1,   464,    -1,    -1,    -1,
+         -1,    -1,    -1,   458,    -1,   459,   460,
+         -1,    -1,    -1,    -1,    -1,    -1,   461,
+         -1,    -1,    -1,    -1,   462,    -1,    -1,
+         -1,    -1,   463,    -1,    -1,    -1,    -1,
+         -1,    -1,    -1,    -1,   464,    -1,    -1,
          -1,    -1,    -1,   465,    -1,    -1,    -1,
+         -1,    -1,    -1,   466,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
-         -1,    -1,    -1,    -1,   466,    -1,    -1,
+         -1,    -1,    -1,    -1,   467,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
-         -1,    -1,   467,    -1,    -1,    -1,   468,
+         -1,    -1,   468,    -1,    -1,    -1,   469,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
-         -1,    -1,    -1,    -1,    -1,    -1,   469,
+         -1,    -1,    -1,    -1,    -1,    -1,   470,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
@@ -1354,22 +1356,22 @@ std_name_hint_lookup::find (const char *str, size_t len)
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
-         -1,   470,    -1,    -1,    -1,    -1,    -1,
+         -1,   471,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
-         -1,    -1,    -1,   471,    -1,   472,    -1,
+         -1,    -1,    -1,   472,    -1,   473,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
-         -1,    -1,   473,    -1,    -1,    -1,    -1,
+         -1,    -1,   474,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
-         -1,    -1,    -1,    -1,    -1,   474,    -1,
-         -1,   475,    -1,    -1,    -1,    -1,    -1,
+         -1,    -1,    -1,    -1,    -1,   475,    -1,
+         -1,   476,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
-        476,    -1,    -1,    -1,    -1,    -1,    -1,
+        477,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
@@ -1380,14 +1382,14 @@ std_name_hint_lookup::find (const char *str, size_t len)
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
-         -1,    -1,    -1,    -1,   477,    -1,    -1,
+         -1,    -1,    -1,    -1,   478,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
-         -1,    -1,    -1,   478,   479,   480,    -1,
+         -1,    -1,    -1,   479,   480,   481,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
-         -1,    -1,    -1,    -1,    -1,   481,    -1,
+         -1,    -1,    -1,    -1,    -1,   482,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
@@ -1402,12 +1404,12 @@ std_name_hint_lookup::find (const char *str, size_t len)
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
-         -1,   482,    -1,    -1,    -1,    -1,    -1,
+         -1,   483,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
-         -1,    -1,    -1,   483,    -1,    -1,    -1,
+         -1,    -1,    -1,   484,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
@@ -1415,12 +1417,12 @@ std_name_hint_lookup::find (const char *str, size_t len)
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
-         -1,    -1,    -1,    -1,    -1,   484,    -1,
          -1,    -1,    -1,    -1,    -1,   485,    -1,
+         -1,    -1,    -1,    -1,    -1,   486,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
          -1,    -1,    -1,    -1,    -1,    -1,    -1,
-        486
+        487
     };
 
   if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
diff --git a/gcc/testsuite/g++.dg/cpp26/observable-checkpoint.C 
b/gcc/testsuite/g++.dg/cpp26/observable-checkpoint.C
new file mode 100644
index 00000000000..886cda7ae33
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp26/observable-checkpoint.C
@@ -0,0 +1,24 @@
+// P1494R5+P3641R0 - Partial program correctness.
+// { dg-do compile { target c++11 } }
+// { dg-additional-options "-fdump-tree-optimized -Wno-return-type -O" }
+// { dg-final { scan-tree-dump  {\+\s42} "optimized" } }
+// { dg-final { scan-tree-dump  {__builtin_observable_checkpoint} "optimized" 
} }
+
+int x = 0;
+
+int
+here_b_ub ()
+{
+  // missing return triggers UB (we must ignore the warning for this test). 
+}
+
+int
+main ()
+{
+  __builtin_printf (" start \n");
+  x += 42;
+  // Without this checkpoint the addition above is elided (along with the rest
+  // of main).
+  __builtin_observable_checkpoint ();
+  here_b_ub ();
+}
-- 
2.39.2 (Apple Git-143)

Reply via email to