Skip to content

Commit

Permalink
Merge branch 'main' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy-rifkin committed Sep 13, 2024
2 parents f811c62 + b90077a commit b7461aa
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 12 deletions.
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
- [libassert 2.1.1](#libassert-211)
- [libassert 2.1.0](#libassert-210)
- [libassert 2.0.2](#libassert-202)
- [libassert 2.0.1](#libassert-201)
- [libassert 2.0.0](#libassert-200)
Expand All @@ -9,6 +11,29 @@
- [libassert 1.1](#libassert-11)
- [libassert 1.0 🎉](#libassert-10-)

## libassert 2.1.1

Fixed:
- ODR issue due to libassert and cpptrace both using the same formatting code https://github.com/jeremy-rifkin/libassert/issues/103
- Worked around old MSVC ICE
- False-positive warnings on gcc about null pointers

Other changes:
- Bumped default cpptrace to v0.7.1

## libassert 2.1.0

Added:
- Added software breakpoints to make assertion failures more debugger-friendly
- Added ANSI color support for catch2 integration now that it is supported in catch v3.6.0

Fixed:
- Fixed checking of stringifiable containers for types with `operator<<` overloads and fmt specializations

Other:
- Added support for gcc 8
- Improved testing

## libassert 2.0.2

Fixed:
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ set(package_name "libassert")
# create base project
project(
libassert
VERSION 2.0.2
VERSION 2.1.1
DESCRIPTION "The most over-engineered C++ assertion library"
HOMEPAGE_URL "https://github.com/jeremy-rifkin/libassert"
LANGUAGES CXX
Expand Down Expand Up @@ -51,7 +51,7 @@ set(LIBASSERT_MAGIC_ENUM_REPO "https://github.com/Neargye/magic_enum.git")
set(LIBASSERT_MAGIC_ENUM_TAG "e55b9b54d5cf61f8e117cafb17846d7d742dd3b4") # v0.9.5

set(LIBASSERT_CPPTRACE_REPO "https://github.com/jeremy-rifkin/cpptrace.git")
set(LIBASSERT_CPPTRACE_TAG "06226ee2aa6a615a63af9d73d69e522c10093dd2") # v0.6.0
set(LIBASSERT_CPPTRACE_TAG "06eb15bda66c5d060f45740b179e80be8e355645") # v0.7.1

# obtain cpptrace
if(LIBASSERT_USE_EXTERNAL_CPPTRACE)
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ include(FetchContent)
FetchContent_Declare(
libassert
GIT_REPOSITORY https://github.com/jeremy-rifkin/libassert.git
GIT_TAG v2.0.2 # <HASH or TAG>
GIT_TAG v2.1.1 # <HASH or TAG>
)
FetchContent_MakeAvailable(libassert)
target_link_libraries(your_target libassert::assert)
Expand Down Expand Up @@ -847,7 +847,7 @@ include(FetchContent)
FetchContent_Declare(
libassert
GIT_REPOSITORY https://github.com/jeremy-rifkin/libassert.git
GIT_TAG v2.0.2 # <HASH or TAG>
GIT_TAG v2.1.1 # <HASH or TAG>
)
FetchContent_MakeAvailable(libassert)
target_link_libraries(your_target libassert::assert)
Expand All @@ -862,7 +862,7 @@ information.

```sh
git clone https://github.com/jeremy-rifkin/libassert.git
git checkout v2.0.2
git checkout v2.1.1
mkdir libassert/build
cd libassert/build
cmake .. -DCMAKE_BUILD_TYPE=Release
Expand Down Expand Up @@ -898,7 +898,7 @@ you when installing new libraries.

```ps1
git clone https://github.com/jeremy-rifkin/libassert.git
git checkout v2.0.2
git checkout v2.1.1
mkdir libassert/build
cd libassert/build
cmake .. -DCMAKE_BUILD_TYPE=Release
Expand All @@ -916,7 +916,7 @@ To install just for the local user (or any custom prefix):

```sh
git clone https://github.com/jeremy-rifkin/libassert.git
git checkout v2.0.2
git checkout v2.1.1
mkdir libassert/build
cd libassert/build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME/wherever
Expand Down Expand Up @@ -965,7 +965,7 @@ Libassert is available through conan at https://conan.io/center/recipes/libasser

```
[requires]
libassert/2.0.2
libassert/2.1.1
[generators]
CMakeDeps
CMakeToolchain
Expand Down
7 changes: 7 additions & 0 deletions include/libassert/stringification.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,14 @@ namespace libassert::detail {
return "nullptr";
}
}
#if LIBASSERT_IS_GCC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wnonnull"
#endif
return stringification::stringify(std::string_view(v));
#if LIBASSERT_IS_GCC
#pragma GCC diagnostic pop
#endif
} else if constexpr(std::is_pointer_v<T> || std::is_function_v<T>) {
return stringification::stringify_pointer_value(reinterpret_cast<const void*>(v));
} else if constexpr(is_smart_pointer<T>) {
Expand Down
6 changes: 3 additions & 3 deletions src/microfmt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ namespace libassert::microfmt {
}
};
for(; it != fmt_end; it++) {
if((*it == '{' || *it == '}') && peek(1) == *it) { // parse {{ and }}}} escapes
if((*it == '{' || *it == '}') && peek(1) == *it) { // parse {{ and }} escapes
it++;
} else if(*it == '{' && it + 1 != fmt_end) {
auto saved_it = it;
Expand Down Expand Up @@ -270,8 +270,9 @@ namespace libassert::microfmt {
return detail::format<sizeof...(args)>(fmt.begin(), fmt.end(), {detail::format_value(args)...});
}

// working around an old msvc bug https://godbolt.org/z/88T8hrzzq mre: https://godbolt.org/z/drd8echbP
inline std::string format(std::string_view fmt) {
return detail::format<0>(fmt.begin(), fmt.end(), {});
return detail::format<1>(fmt.begin(), fmt.end(), {detail::format_value(1)});
}
#endif

Expand All @@ -280,7 +281,6 @@ namespace libassert::microfmt {
return detail::format<sizeof...(args)>(fmt, fmt + std::strlen(fmt), {detail::format_value(args)...});
}

// working around an old msvc bug https://godbolt.org/z/88T8hrzzq mre: https://godbolt.org/z/drd8echbP
inline std::string format(const char* fmt) {
return detail::format<1>(fmt, fmt + std::strlen(fmt), {detail::format_value(1)});
}
Expand Down
14 changes: 13 additions & 1 deletion src/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ namespace libassert::detail {
}
};

// note: the use of U here is mainly to workaround a gcc 8 issue https://godbolt.org/z/bdsWhdGj3
#if LIBASSERT_IS_GCC && LIBASSERT_GCC_VERSION < 900
// note: the use of U here is to workaround a gcc 8 issue https://godbolt.org/z/bdsWhdGj3
template<typename T, typename U, std::size_t N, std::size_t... I>
constexpr std::array<std::remove_cv_t<T>, N> to_array_impl(U(&&a)[N], std::index_sequence<I...>) {
return {{std::move(a[I])...}};
Expand All @@ -106,6 +107,17 @@ namespace libassert::detail {
constexpr std::array<std::remove_cv_t<T>, N> to_array(U(&&a)[N]) {
return to_array_impl<T>(std::move(a), std::make_index_sequence<N>{});
}
#else
// unfortunately the above workaround ICEs MSVC https://godbolt.org/z/bjMEcY9fM
template<typename T, std::size_t N, std::size_t... I>
constexpr std::array<std::remove_cv_t<T>, N> to_array_impl(T(&&a)[N], std::index_sequence<I...>) {
return {{std::move(a[I])...}};
}
template<typename T, std::size_t N>
constexpr std::array<std::remove_cv_t<T>, N> to_array(T(&&a)[N]) {
return to_array_impl<T>(std::move(a), std::make_index_sequence<N>{});
}
#endif

template<typename A, typename B>
constexpr void constexpr_swap(A& a, B& b) {
Expand Down

0 comments on commit b7461aa

Please sign in to comment.