SOLVED "value optimized out " C++ error
-
SOLVED As suspected , passing parameters to object was incomplete and incorrect. Many thanks for all support received.
It is not clear, but I suspect the compiler has optimized it to something like:
MainWindow_C_CODE_FORM *MWCCF_List = new MainWindow_C_CODE_FORM(nullptr, (QStringList){ " Process basic hcitool commands "," I/O hcitool "," DEBUG Trace " });
assuming that
QSL
is not used anywhere else. -
SOLVED As suspected , passing parameters to object was incomplete and incorrect. Many thanks for all support received.
Warning messages out of context are not very helpful. We don't know for at fact that the messages you provided to us are anything to do with the supplied code. IMHO it seems highly unlikely that the value being optimized out is responsible for the possible memory leak. If the compiler can reason that it can optimize away a variable, it should know that no memory clean up is needed. But cleanup may be part of the the expected tasks of the programmer, and adding it in (if needed) might remove both warnings. Start by fixing the issue you have passing the QWidget correctly. There's no telling what doing it wrong might be doing internally. It sounds like a recipe for invoking undefined behavior. If the warnings persist after fixing the calling issue, then start by turning off optimization. If you're on Linux, you might also make sure that you're including debug symbols (-g flag). Depending on what "the tool" is, adding in debugging symbols might help narrow down the origin of the memory leak. Consult the documentation for your IDE (QT Creator?) on how you go about setting the optimization level, and turning on inclusion of debug symbols in the executable.
Keep Calm and Carry On
-
SOLVED As suspected , passing parameters to object was incomplete and incorrect. Many thanks for all support received.
This is just an educated guess on my part, and I'm not a C/C++ expert by any means. Maybe the compiler is telling you that it's discarding the copy of the QStringList that is being created when you pass by value. (Especially since the value is not being used inside the function, I think the compiler might be optimising it away and letting you know.)
The difficult we do right away... ...the impossible takes slightly longer.