Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-14279

"Convert to Stack Variable" generates invalid code

XMLWordPrintable

    • 4b5315bd7cac5fa9ae48244e559d4ee5edd08612

      1. Open a C++-file with the following lines:
        QString *s = new QString();
        s->length();
        

        This is valid C++.

      2. Right-click on the declaration of s and select "Refactor" -> "Convert to Stack Variable" from the context menu.
        The code will be changed to:
        QString s = ;
        s.length();
        

        This is invalid code.

      The code should remain valid. It could be change to this instead:

      QString s;
      s.length();
      

      It's strange that this works correctly when s is declared as auto s instead of QString *s.

        For Gerrit Dashboard: QTCREATORBUG-14279
        # Subject Branch Project Status CR V

            jbornema Joerg Bornemann
            rlohning Robert Löhning
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes