Skip to content

Commit

Permalink
Fix fold expression argument evaluation
Browse files Browse the repository at this point in the history
  • Loading branch information
odygrd committed May 17, 2024
1 parent 8cd87ce commit 32fa5ec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
- Fix bug in `TransitEvent` when dynamic log level is used ([#427](https://github.com/odygrd/quill/pull/427))
- Fix build error for Intel compiler classic ([#414](https://github.com/odygrd/quill/pull/414))
- Added `JsonConsoleHandler` ([#413](https://github.com/odygrd/quill/issues/413))
- Fix fold expression argument evaluation. This bug could occur when logging c style strings

## v3.8.0

Expand Down
6 changes: 5 additions & 1 deletion quill/include/quill/detail/Serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,12 @@ template <typename... Args>
QUILL_NODISCARD QUILL_ATTRIBUTE_HOT inline size_t calculate_args_size_and_populate_string_lengths(
QUILL_MAYBE_UNUSED size_t* c_style_string_lengths, Args const&... args) noexcept
{
// Do not use a fold expression for sequential evaluation
QUILL_MAYBE_UNUSED uint32_t c_style_string_lengths_index{0};
return (0u + ... + calculate_arg_size_and_string_length(c_style_string_lengths, c_style_string_lengths_index, args));
size_t total_size{0};
((total_size += calculate_arg_size_and_string_length(c_style_string_lengths, c_style_string_lengths_index, args)),
...);
return total_size;
}

/**
Expand Down

0 comments on commit 32fa5ec

Please sign in to comment.