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 compiler warnings in public header files #1856

Closed

Conversation

noizefloor
Copy link

core.h: buffer had virtual functions but the dtor was not virtual.

format.f: fix two sign conversions warnings

This warnings occurred on clang and gcc with -Wsign-conversion and -Wnon-virtual-dtor.

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

core.h: buffer had virtual functions but the dtor was not virtual.

format.f: fix two sign conversions warnings
Copy link
Contributor

@vitaut vitaut left a comment

Choose a reason for hiding this comment

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

Thanks for the PR.

@@ -669,7 +669,7 @@ template <typename T> class buffer {
size_(sz),
capacity_(cap) {}

~buffer() = default;
virtual ~buffer() = default;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is intentional.

Copy link
Author

Choose a reason for hiding this comment

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

Is the idea behind that to keep the vtable as small as possible? If that's the case maybe by using CRTP we could get rid of the vtable at all and satisfy my compiler ;)

Copy link
Contributor

Choose a reason for hiding this comment

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

http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rc-dtor-virtual. CRTP is not needed here, I suggest suppressing the useless warning.

@@ -3493,7 +3493,7 @@ inline std::string to_string(T value) {
// The buffer should be large enough to store the number including the sign or
// "false" for bool.
constexpr int max_size = detail::digits10<T>() + 2;
char buffer[max_size > 5 ? max_size : 5];
char buffer[max_size > 5 ? static_cast<size_t>(max_size) : 5];
Copy link
Contributor

Choose a reason for hiding this comment

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

static_cast -> to_unsigned

@vitaut
Copy link
Contributor

vitaut commented Sep 17, 2020

Partially merged in 45da432. Thanks!

@vitaut vitaut closed this Sep 17, 2020
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