'a' may be used uninitialized in this function
Solved
General and Desktop
-
I define a variable: int a.
Then I assigned a=query.value(0).toInt(). (I used qt to connect to mysql)
Then I used a in if().
But when I built the project it warned me "'a' may be used uninitialized in this function"
What happened to my project.
Platform: Windows 10.
Qt: 5.9.1
mysql: 5.7.18 -
Hi,
As silly as it may sound: exactly what the compiler told you.
Without the full code, here's my educated guess:
somewhere in your function: int a; somewhere else in the same function: if (query.next()) { a = query.value(0).toInt() } if (a == 42) { //<< if query.next() returned false, a is still uninitialised hence the warning. qDebug() << "The life, the universe and the rest"; }
-
Hi,
When u declare the variable make sure u initialize the variables, to avoid warnings.
Thanks,
-
@Pradeep-Kumar How to initialize the variables?
Maybe I don't down that code, sorry.