Details
-
Bug
-
Resolution: Done
-
P4: Low
-
5.1.0 , 5.1.1
-
None
-
409655f3451815930b70a71baa175ab9f34467ed
Description
Hello!
We want to compile our code with the gcc compiler flag "-Wold-style-cast".
Trying that we found a usage of an old style cast:
--- a/src/xmlpatterns/api/qabstractxmlnodemodel.h +++ b/src/xmlpatterns/api/qabstractxmlnodemodel.h @@ -95,7 +95,7 @@ namespace QPatternist /* Constructing to qptrdiff means we avoid the warning "cast to pointer * from integer of different size." */ - return (void *)qptrdiff(data); + return reinterpret_cast<void *>(qptrdiff(data)); } Data additionalData;
Please fix this one and all other C style casts in Qt5.
C style casts are not necessary in C++ code and can cause ugly bugs.
For example this code would compile without an error:
void myFunc(const Type1 &var) const { Type2 &my_var = (Type2 &)var; }
BR Gerhard
Attachments
For Gerrit Dashboard: QTBUG-32735 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
62088,2 | Replace use of C-style cast with something that is not a cast. | stable | qt/qtxmlpatterns | Status: MERGED | +2 | 0 |
62302,1 | Remove C-style casts from public headers | master | qt/qt3d | Status: MERGED | +2 | 0 |
70402,3 | QAbstractXmlNodeModel: avoid undefined behavior | stable | qt/qtxmlpatterns | Status: MERGED | +2 | 0 |