Unsolved QT 5.12.0 qtestcase.h(418) Warrning C4805
-
In this part i have warrning:
E:\QT\5.12.0\msvc2017\include\QtTest\qtestcase.h(418): warning C4805: '==': unsafe mix of type 'const T1' and type 'const T2' in operation
1> with
1> [
1> T1=bool
1> ]
1> and
1> [
1> T2=int
1> ] (compiling source file Tests.cpp)
1>C:\Users\M91P\source\repos\Newmen_Style\newmen_prices_calc\newmen_prices_calc\Tests.cpp(32): note: see reference to function template instantiation 'bool QTest::qCompare<bool,int>(const T1 &,const T2 &,const char *,const char *,const char *,int)' being compiled
1> with
1> [
1> T1=bool,
1> T2=int
1> ]Can i fix this with:
template <typename T1, typename T2>
inline bool qCompare(const T1 &t1, const T2 &t2, const char *actual, const char *expected,
const char *file, int line)
{
return compare_helper(t1 == static_cast<T1>(t2), "Compared values are not the same",
toString(t1), toString(t2), actual, expected, file, line);
}??
Thank You for answer.
-
Hi,
What code is triggering that warning ?
And the answer is no, you are currently comparing two different things so if there's something you should change it's not the testing framework as it is complaining for the right reason.
-
@SGaist said in QT 5.12.0 qtestcase.h(418) Warrning C4805:
Hi,
What code is triggering that warning ?
And the answer is no, you are currently comparing two different things so if there's something you should change it's not the testing framework as it is complaining for the right reason.
Fixed, my fault, il compare bool with int.
-
@Maciek0 said in QT 5.12.0 qtestcase.h(418) Warrning C4805:
@SGaist said in QT 5.12.0 qtestcase.h(418) Warrning C4805:
Hi,
What code is triggering that warning ?
And the answer is no, you are currently comparing two different things so if there's something you should change it's not the testing framework as it is complaining for the right reason.
Fixed, my fault, il compare bool with int.
Great !
Since you have it working now, please mark the thread as solved using the "Topic Tools" button so other forum users may know a solution has been found :)