GNU bug report logs - #11223
24.0.94; C++11 initializer lists cause wrong indentation

Previous Next

Packages: cc-mode, emacs;

Reported by: Moritz Bunkus <moritz <at> bunkus.org>

Date: Wed, 11 Apr 2012 16:05:03 UTC

Severity: normal

Found in version 24.0.94

Fixed in version 24.5

Done: Alex <agrambot <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Moritz Bunkus <moritz <at> bunkus.org>
To: 11223 <at> debbugs.gnu.org
Subject: bug#11223: 24.0.94; C++11 initializer lists cause wrong indentation
Date: Wed, 11 Apr 2012 14:45:51 +0200
C++11 introduces the use of { } as object initializer lists instead of
the usual ( ). Using them often causes Emacs & cc-mode to use very
strange indentation. One example is below.

Tested both with c-version 5.32.2 and 5.33.

How to reproduce:

Save the text between the ===== lines into a file, e.g. "test.cc". Start
Emacs with or without -Q on the file. Select the whole buffer, run
`indent-region`.

============================================================
class Foo: public QThingy {
protected:
  SomeObject thingy;
  std::string whatever;
public:
  Foo()
    : thingy{ utilityFunction(42, QList<int>{} << 42 << 54) }
                                                  , whatever{"broken"}
  {
  }
};

class Foo: public QThingy {
protected:
  SomeObject thingy;
  std::string whatever;
public:
  Foo()
    : thingy( utilityFunction(42, QList<int> << 42 << 54) )
    , whatever( "working" )
  {
  }
};
============================================================

In GNU Emacs 24.0.94.1 (x86_64-pc-linux-gnu, GTK+ Version 3.2.0)
 of 2012-03-19 on rhenium, modified by Debian

--
If Darl McBride was in charge, he'd probably make marriage
unconstitutional too, since clearly it de-emphasizes the commercial
nature of normal human interaction, and probably is a major impediment
to the commercial growth of prostitution. - Linus Torvalds




This bug report was last modified 8 years and 345 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.