Skip to content

Commit

Permalink
ignore clang warning
Browse files Browse the repository at this point in the history
  • Loading branch information
braxtons12 committed Sep 21, 2024
1 parent c579537 commit 60fd22c
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions include/hyperion/platform/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ namespace hyperion {
constexpr auto trim_separators([[maybe_unused]] string_literal<Chars...> literal) noexcept {
constexpr auto new_size = []() {
constexpr auto array = std::array{Chars...};
auto size = array.size();
auto size = array.size();
for(const auto& c : array) {
if (c == '\'') {
if(c == '\'') {
size--;
}
}
Expand Down Expand Up @@ -197,16 +197,21 @@ namespace hyperion {
= str.size() > 2 && str[0] == '0' && (str[1] == 'b' || str[1] == 'B');

if constexpr(std::is_floating_point_v<Type>
&& (std::is_same_v<fmax, f64>
|| !std::is_same_v<Type, fmax>)) {
&& (std::is_same_v<fmax, f64> || !std::is_same_v<Type, fmax>))
{
if(!is_hex && !is_binary) {
constexpr auto trimmed = trim_separators(string_literal<Chars...>{});
Type res = 0;
auto result = fast_float::from_chars(
&(trimmed[0]),
&(trimmed[0]) + trimmed.size(),
res
);
#if HYPERION_PLATFORM_COMPILER_IS_CLANG
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunsafe-buffer-usage"
#endif // HYPERION_PLATFORM_COMPILER_IS_CLANG
auto result = fast_float::from_chars(&(trimmed[0]),
&(trimmed[0]) + trimmed.size(),
res);
#if HYPERION_PLATFORM_COMPILER_IS_CLANG
#pragma GCC diagnostic pop
#endif // HYPERION_PLATFORM_COMPILER_IS_CLANG
if(result.ptr != trimmed.end()) {
if(result.ec == std::errc::invalid_argument) {
return {.status = literal_status::InvalidCharacterSequence};
Expand Down

0 comments on commit 60fd22c

Please sign in to comment.