diff --git a/doc/modules/ROOT/pages/design.adoc b/doc/modules/ROOT/pages/design.adoc index 4e7d3ee..dd9db51 100644 --- a/doc/modules/ROOT/pages/design.adoc +++ b/doc/modules/ROOT/pages/design.adoc @@ -176,6 +176,8 @@ Stacktrace: 7# 0x0000000000003925 in bin.v2/libs/safe_numbers/test/basic_usage_stacktrace.test/gcc-11/debug/x86_64/cxxstd-20-iso/threading-multi/visibility-hidden/basic_usage_stacktrace ---- +To see these yourself see the xref:examples.adoc#examples_basic_usage_stacktrace[Basic Usage with Diagnostic Information Example]. + == Runtime Overflow Policies Different domains require different responses to overflow: diff --git a/doc/modules/ROOT/pages/examples.adoc b/doc/modules/ROOT/pages/examples.adoc index 023d8b0..e5bd60d 100644 --- a/doc/modules/ROOT/pages/examples.adoc +++ b/doc/modules/ROOT/pages/examples.adoc @@ -36,7 +36,48 @@ Error Detected: Overflow detected in unsigned addition include::example$basic_usage_stacktrace.cpp[] ---- -Output: +Output on Linux x64: +---- +./boost/safe_numbers/detail/unsigned_integer_basis.hpp(278): Throw in function boost::safe_numbers::detail::add_helper::apply(boost::safe_numbers::detail::unsigned_integer_basis, boost::safe_numbers::detail::unsigned_integer_basis):: +Dynamic exception type: boost::wrapexcept +std::exception::what: Overflow detected in u8 addition + +Stacktrace: + 0# 0x000000000000B19C in bin.v2/libs/safe_numbers/test/basic_usage_stacktrace.test/gcc-11/debug/x86_64/cxxstd-20-iso/threading-multi/visibility-hidden/basic_usage_stacktrace + 1# 0x00000000000099D0 in bin.v2/libs/safe_numbers/test/basic_usage_stacktrace.test/gcc-11/debug/x86_64/cxxstd-20-iso/threading-multi/visibility-hidden/basic_usage_stacktrace + 2# 0x0000000000009AE0 in bin.v2/libs/safe_numbers/test/basic_usage_stacktrace.test/gcc-11/debug/x86_64/cxxstd-20-iso/threading-multi/visibility-hidden/basic_usage_stacktrace + 3# 0x000000000000820A in bin.v2/libs/safe_numbers/test/basic_usage_stacktrace.test/gcc-11/debug/x86_64/cxxstd-20-iso/threading-multi/visibility-hidden/basic_usage_stacktrace + 4# 0x0000000000003A1E in bin.v2/libs/safe_numbers/test/basic_usage_stacktrace.test/gcc-11/debug/x86_64/cxxstd-20-iso/threading-multi/visibility-hidden/basic_usage_stacktrace + 5# 0x0000000000029D90 in /lib/x86_64-linux-gnu/libc.so.6 + 6# __libc_start_main in /lib/x86_64-linux-gnu/libc.so.6 + 7# 0x0000000000003925 in bin.v2/libs/safe_numbers/test/basic_usage_stacktrace.test/gcc-11/debug/x86_64/cxxstd-20-iso/threading-multi/visibility-hidden/basic_usage_stacktrace +---- + +Output on MSVC x64 +---- +D:\a\safe_numbers\boost-root\boost/safe_numbers/detail/unsigned_integer_basis.hpp(278): Throw in function void __cdecl boost::safe_numbers::detail::add_helper<0,unsigned char>::apply::::operator ()(void) const +Dynamic exception type: struct boost::wrapexcept +std::exception::what: Overflow detected in u8 addition + +Stacktrace: + 0# RtlDispatchException in C:\Windows\SYSTEM32\ntdll.dll + 1# KiUserExceptionDispatch in C:\Windows\SYSTEM32\ntdll.dll + 2# RaiseException in C:\Windows\System32\KERNELBASE.dll + 3# _CxxThrowException at D:\a\_work\1\s\src\vctools\crt\vcruntime\src\eh\throw.cpp:79 + 4# boost::throw_exception at D:\a\safe_numbers\boost-root\boost\throw_exception.hpp:171 + 5# `boost::safe_numbers::detail::add_helper<0,unsigned char>::apply'::`2'::::operator() at D:\a\safe_numbers\boost-root\boost\safe_numbers\detail\unsigned_integer_basis.hpp:278 + 6# boost::safe_numbers::detail::add_helper<0,unsigned char>::apply at D:\a\safe_numbers\boost-root\boost\safe_numbers\detail\unsigned_integer_basis.hpp:318 + 7# boost::safe_numbers::detail::operator+ at D:\a\safe_numbers\boost-root\boost\safe_numbers\detail\unsigned_integer_basis.hpp:486 + 8# main at D:\a\safe_numbers\boost-root\libs\safe_numbers\examples\basic_usage_stacktrace.cpp:24 + 9# invoke_main at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:79 +10# __scrt_common_main_seh at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288 +11# __scrt_common_main at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:331 +12# mainCRTStartup at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_main.cpp:17 +13# BaseThreadInitThunk in C:\Windows\System32\KERNEL32.DLL +14# RtlUserThreadStart in C:\Windows\SYSTEM32\ntdll.dll +---- + +Output on Other Platforms: ---- ./boost/safe_numbers/detail/unsigned_integer_basis.hpp(278): Throw in function ... Dynamic exception type: boost::wrapexcept @@ -44,6 +85,22 @@ std::exception::what: Overflow detected in u8 addition ---- ==== +[#examples_basic_bounded_usage] +== Basic Bounded Usage + +.This https://github.com/boostorg/safe_numbers/blob/develop/examples/basic_bounded_usage.cpp[example] demonstrates the default behavior where bounded arithmetic that exceeds the declared range throws an exception. +==== +[source, c++] +---- +include::example$basic_bounded_usage.cpp[] +---- + +Output: +---- +Error Detected: bounded_uint<0, 100> addition result out of range +---- +==== + [#examples_construction] == Construction and Conversion