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

Local refactoring doesn't cover variable occurrences within sizeof()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Not Evaluated Not Evaluated
    • Qt Creator 2.4.0
    • Qt Creator 2.2.0, Qt Creator 2.4.0-beta
    • C/C++/Obj-C++ Support
    • None
    • Windows XP SP3
    • 1c3c50945dbd4d3473ba431c9e8c31e807078f3a

      Refactoring doesn't work correctly if the variable is used in sizeof().
      If you trigger refactoring outside of sizeof(), only the occurences
      outside sizeof are changed (wrong_behaviour.png).

      If you trigger inside the sizeof(), all occurences are marked (better_behaviour.png), but the global search & replace dialog appears (global_replace.png).

      test.cpp
      #include "mainwindow.h"
      #include "ui_mainwindow.h"
      
      MainWindow::MainWindow(QWidget *parent) :
      	QMainWindow(parent),
      	ui(new Ui::MainWindow)
      {
      	ui->setupUi(this);
      
      	char buf[256];
      
      	strncpy(buf, "test", sizeof(buf));
      	buf[sizeof(buf)] = 0;
      }
      
      MainWindow::~MainWindow()
      {
      	delete ui;
      }
      
      

        1. better_behaviour.PNG
          65 kB
          car sprayer
        2. global_replace.PNG
          77 kB
          car sprayer
        3. wrong_behaviour.PNG
          64 kB
          car sprayer
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            erikv Erik Verbruggen
            carsprayer car sprayer
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes