Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some warnings #1667

Merged
merged 4 commits into from
May 7, 2020
Merged

Fix some warnings #1667

merged 4 commits into from
May 7, 2020

Conversation

peterbell10
Copy link
Contributor

This fixes a few warnings I was seeing compiling with clang:

  • -Wsigned-enum-bitfield from using standard enums in a bitfield, fixed by giving them an unsigned underlying type.
  • -Wundefined-func-template from templates without definitions, fixed by adding extern template declarations.
  • -Wsign-conversion from constructing a string_view with an int size, fixed with internal::to_unsigned.

I agree that my contributions are licensed under the {fmt} license, and agree to future changes to the licensing.

@vitaut
Copy link
Contributor

vitaut commented May 6, 2020

Thanks for the PR. Please move all the extern template declarations to

fmt/include/fmt/format.h

Lines 3337 to 3340 in 59fe455

#ifndef FMT_HEADER_ONLY
extern template format_context::iterator internal::vformat_to(
internal::buffer<char>&, string_view, basic_format_args<format_context>);
#endif
to avoid introducing extra #ifdef blocks.

@vitaut vitaut merged commit 44639b1 into fmtlib:master May 7, 2020
@vitaut
Copy link
Contributor

vitaut commented May 7, 2020

Thanks!

@@ -1022,12 +1022,12 @@ template <typename Char> struct fill_t {
// We cannot use enum classes as bit fields because of a gcc bug
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61414.
namespace align {
enum type { none, left, right, center, numeric };
enum type : uint8_t { none, left, right, center, numeric };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted because of

include/fmt/format.h:1039:19: error: ‘fmt::v6::basic_format_specs<char>::align’ is too small to hold all values of ‘using align_t = enum fmt::v6::align::type {aka enum fmt::v6::align::type}’ [-Werror]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's unfortunate; it looks like there isn't a nice way to satisfy both compilers. I can switch the struct data members to use uint8_t directly, but then we lose the type safety of enums.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants