-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Conversation
core.h: buffer had virtual functions but the dtor was not virtual. format.f: fix two sign conversions warnings
There was a problem hiding this 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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is intentional.
There was a problem hiding this comment.
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 ;)
There was a problem hiding this comment.
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]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static_cast -> to_unsigned
Partially merged in 45da432. Thanks! |
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.