Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-32735

Remove old style cast from qabstractxmlnodemodel.h

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P4: Low
    • 5.2.0
    • 5.1.0 , 5.1.1
    • XML: QtXmlPatterns
    • 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

        Activity

          People

            thiago Thiago Macieira
            gscheikl Gerhard Scheikl
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes