mirror of git://gcc.gnu.org/git/gcc.git
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>
This commit is contained in:
parent
9056b5faa8
commit
1e84849cb2
|
@ -1950,6 +1950,15 @@ ftms = {
|
|||
};
|
||||
};
|
||||
|
||||
ftms = {
|
||||
name = observable_checkpoint;
|
||||
values = {
|
||||
v = 202506;
|
||||
cxxmin = 26;
|
||||
extra_cond = "__has_builtin(__builtin_observable_checkpoint)";
|
||||
};
|
||||
};
|
||||
|
||||
ftms = {
|
||||
name = algorithm_default_value_type;
|
||||
values = {
|
||||
|
|
|
@ -2181,6 +2181,16 @@
|
|||
#endif /* !defined(__cpp_lib_unreachable) */
|
||||
#undef __glibcxx_want_unreachable
|
||||
|
||||
#if !defined(__cpp_lib_observable_checkpoint)
|
||||
# if (__cplusplus > 202302L) && (__has_builtin(__builtin_observable_checkpoint))
|
||||
# define __glibcxx_observable_checkpoint 202506L
|
||||
# if defined(__glibcxx_want_all) || defined(__glibcxx_want_observable_checkpoint)
|
||||
# define __cpp_lib_observable_checkpoint 202506L
|
||||
# endif
|
||||
# endif
|
||||
#endif /* !defined(__cpp_lib_observable_checkpoint) && defined(__glibcxx_want_observable_checkpoint) */
|
||||
#undef __glibcxx_want_observable_checkpoint
|
||||
|
||||
#if !defined(__cpp_lib_algorithm_default_value_type)
|
||||
# if (__cplusplus > 202302L)
|
||||
# define __glibcxx_algorithm_default_value_type 202403L
|
||||
|
|
|
@ -98,6 +98,7 @@
|
|||
#define __glibcxx_want_tuple_element_t
|
||||
#define __glibcxx_want_tuples_by_type
|
||||
#define __glibcxx_want_unreachable
|
||||
#define __glibcxx_want_observable_checkpoint
|
||||
#define __glibcxx_want_tuple_like
|
||||
#define __glibcxx_want_constrained_equality
|
||||
#include <bits/version.h>
|
||||
|
@ -234,6 +235,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cpp_lib_observable_checkpoint // C++ >= 26
|
||||
/// Informs the compiler that prior actions are considered observable.
|
||||
/**
|
||||
* This may be used to limit the extent to which optimisations based on the
|
||||
* assumed unreachability of undefined behaviour can propagate to earlier
|
||||
* code.
|
||||
*
|
||||
* @since C++26
|
||||
*/
|
||||
[[__gnu__::__always_inline__]]
|
||||
inline void
|
||||
observable_checkpoint() noexcept
|
||||
{
|
||||
return __builtin_observable_checkpoint();
|
||||
}
|
||||
#endif
|
||||
|
||||
_GLIBCXX_END_NAMESPACE_VERSION
|
||||
} // namespace
|
||||
|
||||
|
|
|
@ -3337,6 +3337,9 @@ export namespace std
|
|||
#if __cpp_lib_unreachable
|
||||
using std::unreachable;
|
||||
#endif
|
||||
#if __cpp_lib_observable_checkpoint
|
||||
using std::observable_checkpoint;
|
||||
#endif
|
||||
}
|
||||
|
||||
// <valarray>
|
||||
|
|
Loading…
Reference in New Issue