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

"Convert to Stack Variable" generates invalid code

    XMLWordPrintable

Details

    • 4b5315bd7cac5fa9ae48244e559d4ee5edd08612

    Description

      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.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes