Skip to content

Commit

Permalink
fix(gcc): ignore warning for already handled null pointer (#102)
Browse files Browse the repository at this point in the history
[fix: ignore warning for already handled null
pointer](c185bd7)

GCC 13.3 and GCC 14.1 both seem to incorrectly parse the stringification
condition incorrectly, and will warn about null pointers that have
already been returned early from.

---

Unsure if this is the best strategy to solve this, open to revise it.
Followed the same pattern as [how old-style ASSERT(foo &&
"Message")](https://github.com/jeremy-rifkin/libassert/blob/aff047da702316b10219a967f78da352f847b8d0/include/libassert/expression-decomposition.hpp#L120-L132)
was implemented.
  • Loading branch information
steinwurf-sofie authored Aug 24, 2024
1 parent aff047d commit 53bfad1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions include/libassert/stringification.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,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

0 comments on commit 53bfad1

Please sign in to comment.