-
Notifications
You must be signed in to change notification settings - Fork 62
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 GCC warning maybe-uninitialized for PromiseValue<T> constructor #60
Fix GCC warning maybe-uninitialized for PromiseValue<T> constructor #60
Conversation
) | ||
|
||
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") | ||
target_compile_options(qtpromise.tests.auto.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.
I tried to use add_compile_options
but it didn't seem to work. For this test to work, we need to compile it with optimizations, however qtpromise_add_test
function sets optimization level to -O0. What I don't like here is how I have to refer to a test by it's internal name.
935dd56
to
cd084f8
Compare
22ebe5e
to
69b9543
Compare
69b9543
to
5402fe5
Compare
@simonbrunel, hi! Any chance you could take a look please? |
Thanks @Poldraunic for this great PR and sorry for the wait!
I'm always reluctant when things happen magically since it seems the underlying issue is not really solved, neither understood (both linked Qt bugs are now closed, quite old and without any resolution). I'm actually missing the information of which versions of Qt is impacted? (v5, v6 or both?) I remember this PR from @pwuertz which I think fixes a similar warning by using Thoughts? |
@simonbrunel, hi! Thanks for the reply. I am wary of magical fixes as well. For this one, however, issue seems to stem from compiler itself which is basically arcane knowledge. Qt bug reports were made against versions Qt 4 and Qt 5. Furthermore, I couldn't repro this (or similar) warning with Clang/MSVC compilers. That is why I decided explanation from Qt staff was good enough for me. I am seeing this warning on Qt 5.15. I believe I haven't actually tried testing with Qt 6, but I did check the sources for All in all, I am in agreement. I will compile this snippet with Qt 6 later this week and check if it has any difference. As for using Thank you. |
Yes, I think that's the way to go if that suppresses the warning and all tests still pass (I may need to have a look why Travis CI does not want to run tests anymore). |
b68ba17
to
f2bfb19
Compare
@simonbrunel done! I have switched |
Thanks! I'm not sure I would keep the unit tests introduced in this PR. The reason is that the bug was in the Qt lib ( |
@simonbrune, I agree. Will remove later today. |
f2bfb19
to
bc1fada
Compare
@simonbrunel, done! |
Thanks @Poldraunic! I will merge it but first I would like to try to replace Travis CI by GitHub actions to run unit tests (Travis is no free anymore for open source projects). |
…tner<T> In optimized builds (such as -O2) GCC emits "maybe-uninitialized" warning for QSharedPointer<T>::d. This happens only for optimized builds because that is when GCC tracks lifetimes[1]. In a project with lots of QtPromise uses this produces a heap of bogus warnings. This warning has been previously reported to a Qt team, but they're confident it is a compiler bug[2][3]. However, this is a second time and issue raised with QSharedPointer and warnings to it. The first time it was addressed here: simonbrunel#34. [1] https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wmaybe-uninitialized [2] https://bugreports.qt.io/browse/QTBUG-14637 [3] https://bugreports.qt.io/browse/QTBUG-77641
bc1fada
to
0bc9d4d
Compare
@Poldraunic It's now merged, thanks for this really good PR! (and sorry for the long wait) |
Awesome! Thank you very much! |
Use
std::shared_ptr
forPromiseValue<T>::m_data
instead ofQSharedPoitner<T>
In optimized builds (such as -O2) GCC emits "maybe-uninitialized" warning for
QSharedPointer<T>::d
. This happens only for optimized builds because that is when GCC tracks lifetimes[1]. In a project with lots of QtPromise uses this produces a heap of bogus warnings. This warning has been previously reported to a Qt team, but they're confident it is a compiler bug[2][3]. However, this is a second time and issue raised withQSharedPointer
and warnings to it. The first time it was addressed here: #34.GCC output
[1] https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wmaybe-uninitialized
[2] https://bugreports.qt.io/browse/QTBUG-14637
[3] https://bugreports.qt.io/browse/QTBUG-77641