-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Narrower data type and sign conversion warnings in qt_sinks.h #3321
Comments
Which compiler and version? |
Sorry for the delay.
With Clang:
include/spdlog/sinks/qt_sinks.h:163:71: error: implicit conversion changes signedness: 'size_t' (aka 'unsigned long') to 'qsizetype' (aka 'long long') [-Werror,-Wsign-conversion]
163 | color_range_start = QString::fromUtf8(str.data(), msg.color_range_start).size();
| ~~~~~~~ ~~~~^~~~~~~~~~~~~~~~~
include/spdlog/sinks/qt_sinks.h:164:69: error: implicit conversion changes signedness: 'size_t' (aka 'unsigned long') to 'qsizetype' (aka 'long long') [-Werror,-Wsign-conversion]
164 | color_range_end = QString::fromUtf8(str.data(), msg.color_range_end).size();
| ~~~~~~~ ~~~~^~~~~~~~~~~~~~~
include/spdlog/sinks/qt_sinks.h:163:71: error: implicit conversion changes signedness: 'size_t' (aka 'unsigned long') to 'qsizetype' (aka 'long long') [-Werror,-Wsign-conversion]
163 | color_range_start = QString::fromUtf8(str.data(), msg.color_range_start).size();
| ~~~~~~~ ~~~~^~~~~~~~~~~~~~~~~
include/spdlog/sinks/qt_sinks.h:68:5: note: in instantiation of member function 'spdlog::sinks::qt_color_sink<spdlog::details::null_mutex>::sink_it_' requested here
68 | qt_color_sink(QTextEdit *qt_text_edit,
| ^
include/spdlog/sinks/qt_sinks.h:164:69: error: implicit conversion changes signedness: 'size_t' (aka 'unsigned long') to 'qsizetype' (aka 'long long') [-Werror,-Wsign-conversion]
164 | color_range_end = QString::fromUtf8(str.data(), msg.color_range_end).size();
| ~~~~~~~ ~~~~^~~~~~~~~~~~~~~
include/spdlog/sinks/qt_sinks.h:174:45: error: implicit conversion changes signedness: 'const level::level_enum' to 'size_type' (aka 'unsigned long') [-Werror,-Wsign-conversion]
174 | colors_.at(msg.level), // color to apply
| ~~ ~~~~^~~~~
include/spdlog/sinks/qt_sinks.h:163:90: error: implicit conversion loses integer precision: 'qsizetype' (aka 'long long') to 'int' [-Werror,-Wshorten-64-to-32]
163 | color_range_start = QString::fromUtf8(str.data(), msg.color_range_start).size();
| ~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
include/spdlog/sinks/qt_sinks.h:164:86: error: implicit conversion loses integer precision: 'qsizetype' (aka 'long long') to 'int' [-Werror,-Wshorten-64-to-32]
164 | color_range_end = QString::fromUtf8(str.data(), msg.color_range_end).size();
| ~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~ |
This is due to the design of the
@davidebeatrici If you trust Qt, you can avoid the warning by sending a PR that casts two types with |
The same size, not the same type. The documentation is correct. Qt's size type used to be a 32 bit signed integer (
Yeah. Let's wait for @gabime's feedback though. |
PR is welcome. But please check sure it won't crash if the casted size_t is huge and casts to negative |
The text was updated successfully, but these errors were encountered: