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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions include/fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.

}
using align_t = align::type;

namespace sign {
enum type { none, minus, plus, space };
enum type : uint8_t { none, minus, plus, space };
}
using sign_t = sign::type;

Expand Down Expand Up @@ -3337,6 +3337,28 @@ typename buffer_context<Char>::iterator internal::vformat_to(
#ifndef FMT_HEADER_ONLY
extern template format_context::iterator internal::vformat_to(
internal::buffer<char>&, string_view, basic_format_args<format_context>);
namespace internal {
extern template FMT_API std::string grouping_impl<char>(locale_ref loc);
extern template FMT_API std::string grouping_impl<wchar_t>(locale_ref loc);
extern template FMT_API char thousands_sep_impl<char>(locale_ref loc);
extern template FMT_API wchar_t thousands_sep_impl<wchar_t>(locale_ref loc);
extern template FMT_API char decimal_point_impl(locale_ref loc);
extern template FMT_API wchar_t decimal_point_impl(locale_ref loc);
extern template
int format_float<double>(double value, int precision, float_specs specs,
buffer<char>& buf);
extern template
int format_float<long double>(long double value, int precision,
float_specs specs, buffer<char>& buf);
int snprintf_float(float value, int precision, float_specs specs,
buffer<char>& buf) = delete;
extern template
int snprintf_float<double>(double value, int precision, float_specs specs,
buffer<char>& buf);
extern template
int snprintf_float<long double>(long double value, int precision,
float_specs specs, buffer<char>& buf);
}
#endif

template <typename S, typename Char = char_t<S>,
Expand Down
2 changes: 1 addition & 1 deletion include/fmt/printf.h
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ OutputIt basic_printf_context<OutputIt, Char>::format() {
auto str_end = str + specs.precision;
auto nul = std::find(str, str_end, Char());
arg = internal::make_arg<basic_printf_context>(basic_string_view<Char>(
str, nul != str_end ? nul - str : specs.precision));
str, internal::to_unsigned(nul != str_end ? nul - str : specs.precision)));
}
if (specs.alt && visit_format_arg(internal::is_zero_int(), arg))
specs.alt = false;
Expand Down