Skip to content

Commit

Permalink
Fixes #293
Browse files Browse the repository at this point in the history
- Some users wished that Outcome would be clean with `-Wpedantic`, this is now turned on for
the test suite.

Fixes #294
- All use of `assert()` has been replaced with `OUTCOME_ASSERT`, which can be user overridden
at compile time.

Fixes #295
- In git commit 12b14e1 (Aug 11 2022) status code had its
paths changed due to its headers not previously having the right path convention. It was not
realised at the time that in Boost.Outcome this resulted in
`<boost/outcome/experimental/status-code/status-code/headers.hpp>` which is not desirable.
This has now been remedied to remove the double `status-code`, which will obviously break
any Boost.Outcome code which relies on the double `status-code`. Standalone Outcome is unaffected.
  • Loading branch information
ned14 committed Dec 16, 2023
1 parent 645500f commit d4d1966
Show file tree
Hide file tree
Showing 15 changed files with 295 additions and 131 deletions.
4 changes: 2 additions & 2 deletions .boostify
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Files to copy over
include_files = [
(r'include/outcome/experimental/status-code/include/(.*)', r'include/boost/outcome/experimental/status-code/\1'),
(r'include/outcome/experimental/status-code/include/(.*)', r'include/boost/outcome/experimental/\1'),
(r'include/(.*)', r'include/boost/\1'),
r'^doc/src/.*$',
r'^test/.*$',
Expand Down Expand Up @@ -47,7 +47,7 @@ core_macros = {
r'^SYSTEM_ERROR2_': r'BOOST_OUTCOME_SYSTEM_ERROR2_',
r'([^_])SYSTEM_ERROR2_': r'\1BOOST_OUTCOME_SYSTEM_ERROR2_',
r'<outcome/([^>]+)': r'<boost/outcome/\1',
r'status-code/include/': r'status-code/',
r'status-code/include/': r'/',
r'// Boost.Outcome ' : r'',
r'CXX_': r'BOOST_OUTCOME_C_',
}
Expand Down
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,13 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test" AND NOT outcome_IS_DEPENDENCY AND (
endforeach()
endif()

# Turn on pedantic warnings for all tests, examples and snippets
if(NOT MSVC)
foreach(target ${outcome_TEST_TARGETS} ${outcome_EXAMPLE_TARGETS} ${example_bins})
target_compile_options(${target} PUBLIC "-Wpedantic")
endforeach()
endif()

if(OUTCOME_ENABLE_DEPENDENCY_SMOKE_TEST)
set(OUTCOME_SMOKE_TESTS)
add_executable(outcome-dependency-smoke-test_1 "test/tests/core-result.cpp")
Expand Down
23 changes: 23 additions & 0 deletions doc/src/content/changelog/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,29 @@ title = "Changelog"
weight = 80
+++

---
## v2.2.9 ? (Boost 1.85) [[release]](https://github.com/ned14/outcome/releases/tag/v2.2.9)

### Enhancements:

[#293](https://github.com/ned14/outcome/issues/293)
- Some users wished that Outcome would be clean with `-Wpedantic`, this is now turned on for
the test suite.

[#294](https://github.com/ned14/outcome/issues/294)
- All use of `assert()` has been replaced with `OUTCOME_ASSERT`, which can be user overridden
at compile time.

[#295](https://github.com/ned14/outcome/issues/295)
- In git commit 12b14e1533848e9a0f7f3c38e41da0ee4e819770 (Aug 11 2022) status code had its
paths changed due to its headers not previously having the right path convention. It was not
realised at the time that in Boost.Outcome this resulted in
`<boost/outcome/experimental/status-code/status-code/headers.hpp>` which is not desirable.
This has now been remedied to remove the double `status-code`, which will obviously break
any Boost.Outcome code which relies on the double `status-code`. Standalone Outcome is unaffected.

### Bug fixes:

---
## v2.2.8 13th December 2023 (Boost 1.84) [[release]](https://github.com/ned14/outcome/releases/tag/v2.2.8)

Expand Down
2 changes: 1 addition & 1 deletion doc/src/content/reference/policies/base/ub.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This is a special function which does compiler-specific stuff to tell the compil

This may seem highly undesirable. However, it also means that the optimiser can optimise more strongly, and so long as you never actually do execute this branch, you do get higher quality code generation.

If the `NDEBUG` macro is not defined, an `assert(false)` is present. This will cause attempts to execute this function to fail in a very obvious way, but it also generates runtime code to trigger the obvious failure.
If the `NDEBUG` macro is not defined, an `OUTCOME_ASSERT(false)` is present. This will cause attempts to execute this function to fail in a very obvious way, but it also generates runtime code to trigger the obvious failure.

If the `NDEBUG` macro is defined, and the program is compiled with the undefined behaviour sanitiser, attempts to execute this function will trigger an undefined behaviour sanitiser action.

Expand Down
15 changes: 10 additions & 5 deletions include/outcome/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Distributed under the Boost Software License, Version 1.0.
#define OUTCOME_TEXPR(...) typename = decltype(__VA_ARGS__)
#define OUTCOME_TPRED(...) typename = std::enable_if_t<__VA_ARGS__>
#define OUTCOME_REQUIRES(...) requires __VA_ARGS__
/*! AWAITING HUGO JSON CONVERSION TOOL
/*! AWAITING HUGO JSON CONVERSION TOOL
SIGNATURE NOT RECOGNISED
*/
#endif
Expand Down Expand Up @@ -157,14 +157,14 @@ using std::in_place_type;
OUTCOME_V2_NAMESPACE_END
#else
OUTCOME_V2_NAMESPACE_BEGIN
/*! AWAITING HUGO JSON CONVERSION TOOL
/*! AWAITING HUGO JSON CONVERSION TOOL
type definition template <class T> in_place_type_t. Potential doc page: `in_place_type_t<T>`
*/
template <class T> struct in_place_type_t
{
explicit in_place_type_t() = default;
};
/*! AWAITING HUGO JSON CONVERSION TOOL
/*! AWAITING HUGO JSON CONVERSION TOOL
SIGNATURE NOT RECOGNISED
*/
template <class T> constexpr in_place_type_t<T> in_place_type{};
Expand All @@ -178,6 +178,11 @@ OUTCOME_V2_NAMESPACE_END
#define OUTCOME_ADDRESS_OF(...) (&__VA_ARGS__)
#endif

#ifndef OUTCOME_ASSERT
#include <cassert>
#define OUTCOME_ASSERT(...) assert(__VA_ARGS__)
#endif

#ifndef OUTCOME_TRIVIAL_ABI
#if defined(STANDARDESE_IS_IN_THE_HOUSE) || __clang_major__ >= 7
//! Defined to be `[[clang::trivial_abi]]` when on a new enough clang compiler. Usually automatic, can be overriden.
Expand Down Expand Up @@ -353,11 +358,11 @@ namespace detail
{
#if !defined(OUTCOME_DISABLE_EXECINFO)
void *bt[16];
size_t btlen = backtrace(bt, sizeof(bt) / sizeof(bt[0])); // NOLINT
size_t btlen = backtrace(bt, sizeof(bt) / sizeof(bt[0])); // NOLINT
#endif
fprintf(stderr, "FATAL: Outcome throws exception %s with exceptions disabled\n", expr); // NOLINT
#if !defined(OUTCOME_DISABLE_EXECINFO)
char **bts = backtrace_symbols(bt, btlen); // NOLINT
char **bts = backtrace_symbols(bt, btlen); // NOLINT
if(bts != nullptr)
{
for(size_t n = 0; n < btlen; n++)
Expand Down
23 changes: 11 additions & 12 deletions include/outcome/detail/coroutine_support.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ Distributed under the Boost Software License, Version 1.0.
#define OUTCOME_DETAIL_COROUTINE_SUPPORT_HPP

#include <atomic>
#include <cassert>
#include <exception>

#ifndef OUTCOME_COROUTINE_HEADER_TYPE
Expand Down Expand Up @@ -209,7 +208,7 @@ namespace awaitables
void return_value(container_type &&value)
{
OUTCOME_V2_AWAITABLES_DEBUG_PRINTER(this << " promise returns value");
assert(!result_set.load(std::memory_order_acquire));
OUTCOME_ASSERT(!result_set.load(std::memory_order_acquire));
if(result_set.load(std::memory_order_acquire))
{
result.~container_type(); // could throw
Expand All @@ -220,7 +219,7 @@ namespace awaitables
void return_value(const container_type &value)
{
OUTCOME_V2_AWAITABLES_DEBUG_PRINTER(this << " promise returns value");
assert(!result_set.load(std::memory_order_acquire));
OUTCOME_ASSERT(!result_set.load(std::memory_order_acquire));
if(result_set.load(std::memory_order_acquire))
{
result.~container_type(); // could throw
Expand All @@ -231,7 +230,7 @@ namespace awaitables
void unhandled_exception()
{
OUTCOME_V2_AWAITABLES_DEBUG_PRINTER(this << " promise unhandled exception");
assert(!result_set.load(std::memory_order_acquire));
OUTCOME_ASSERT(!result_set.load(std::memory_order_acquire));
if(result_set.load(std::memory_order_acquire))
{
result.~container_type();
Expand Down Expand Up @@ -323,13 +322,13 @@ namespace awaitables
void return_void() noexcept
{
OUTCOME_V2_AWAITABLES_DEBUG_PRINTER(this << " promise returns void");
assert(!result_set.load(std::memory_order_acquire));
OUTCOME_ASSERT(!result_set.load(std::memory_order_acquire));
result_set.store(true, std::memory_order_release);
}
void unhandled_exception()
{
OUTCOME_V2_AWAITABLES_DEBUG_PRINTER(this << " promise unhandled exception");
assert(!result_set.load(std::memory_order_acquire));
OUTCOME_ASSERT(!result_set.load(std::memory_order_acquire));
std::rethrow_exception(std::current_exception()); // throws
}
auto initial_suspend() noexcept
Expand Down Expand Up @@ -431,7 +430,7 @@ namespace awaitables
container_type await_resume()
{
OUTCOME_V2_AWAITABLES_DEBUG_PRINTER(&_h.promise() << " await_resume");
assert(_h.promise().result_set.load(std::memory_order_acquire));
OUTCOME_ASSERT(_h.promise().result_set.load(std::memory_order_acquire));
if(!_h.promise().result_set.load(std::memory_order_acquire))
{
std::terminate();
Expand Down Expand Up @@ -507,7 +506,7 @@ namespace awaitables
}
void return_void() noexcept
{
assert(result_set.load(std::memory_order_acquire) >= 0);
OUTCOME_ASSERT(result_set.load(std::memory_order_acquire) >= 0);
if(result_set.load(std::memory_order_acquire) == 1)
{
result.~container_type(); // could throw
Expand All @@ -516,7 +515,7 @@ namespace awaitables
}
suspend_always yield_value(container_type &&value)
{
assert(result_set.load(std::memory_order_acquire) >= 0);
OUTCOME_ASSERT(result_set.load(std::memory_order_acquire) >= 0);
if(result_set.load(std::memory_order_acquire) == 1)
{
result.~container_type(); // could throw
Expand All @@ -527,7 +526,7 @@ namespace awaitables
}
suspend_always yield_value(const container_type &value)
{
assert(result_set.load(std::memory_order_acquire) >= 0);
OUTCOME_ASSERT(result_set.load(std::memory_order_acquire) >= 0);
if(result_set.load(std::memory_order_acquire) == 1)
{
result.~container_type(); // could throw
Expand All @@ -538,7 +537,7 @@ namespace awaitables
}
void unhandled_exception()
{
assert(result_set.load(std::memory_order_acquire) >= 0);
OUTCOME_ASSERT(result_set.load(std::memory_order_acquire) >= 0);
if(result_set.load(std::memory_order_acquire) == 1)
{
result.~container_type();
Expand Down Expand Up @@ -631,7 +630,7 @@ namespace awaitables
{
_h();
}
assert(p.result_set.load(std::memory_order_acquire) >= 0);
OUTCOME_ASSERT(p.result_set.load(std::memory_order_acquire) >= 0);
if(p.result_set.load(std::memory_order_acquire) < 0)
{
std::terminate();
Expand Down
6 changes: 3 additions & 3 deletions include/outcome/detail/revision.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ Distributed under the Boost Software License, Version 1.0.
*/

// Note the second line of this file must ALWAYS be the git SHA, third line ALWAYS the git SHA update time
#define OUTCOME_PREVIOUS_COMMIT_REF f7892ac2e8ef0a236f324a9111e75824ae55690a
#define OUTCOME_PREVIOUS_COMMIT_DATE "2023-11-17 08:58:53 +00:00"
#define OUTCOME_PREVIOUS_COMMIT_UNIQUE f7892ac2
#define OUTCOME_PREVIOUS_COMMIT_REF 645500fe31c7ffc14299af9651b2ae1c9d6741c9
#define OUTCOME_PREVIOUS_COMMIT_DATE "2023-12-16 20:11:33 +00:00"
#define OUTCOME_PREVIOUS_COMMIT_UNIQUE 645500fe
Loading

0 comments on commit d4d1966

Please sign in to comment.