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

Incorrect indent after return with conditional using an array operator

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Not Evaluated Not Evaluated
    • None
    • Qt Creator 3.6.0
    • C/C++/Obj-C++ Support
    • None
    • Debian/Linux

      The following code causes problems

      int test()
      {
      	int arr[10];
      	bool x = false;
      
      	return x > 0 ? arr[0] : 0;   // <-- All indents following this line are 1 to the right
              }  // <-- wrong indent
      

      A workaround is to use parethesis for the return statement,

          return (x > 0 ? arr[0] : 0);
      

      This only appears to happen with the 2nd (true) statement. Having an array operator in the 3rd (false) position does not result in invalid indentation.

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

            kosjar Nikolai Kosjar
            adamm Adam Majer
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes