1

[Reposted here after a comment from wilx on stackoverflow.com]

Consider the following snippet of C++ code, indented using cc-mode:

auto good1 = f(a,
               {1, 2});   // ((arglist-cont-nonempty 1 15))
auto bad1 = f<1>(a,
  {1, 2});                // ((inexpr-statement) (block-open 36))

auto good2 = f(a,
               b,         // ((arglist-cont-nonempty 68 82))
               {1, 2});   // ((arglist-cont-nonempty 68 82))
auto bad2 = f<1>(a,
                 b        // ((arglist-cont-nonempty 114 130))
  {1, 2});                // ((inexpr-statement) (block-open 114))

auto good3 = f(a,
               b,         // ((arglist-cont-nonempty 151 165))
               {1, 2},    // ((arglist-cont-nonempty 151 165))
               c);

auto bad3 = f<3>(a,
                 b,       // ((arglist-cont-nonempty 209 225))
  {1, 2},                 // ((inexpr-statement) (block-open 209))
                 c);

As you can see, the curly-bracket-arguments {1, 2} are not indented properly when occurring in a templated function call. This is due to them being wrongly labelled as ((inexpr-statement) (block-open X)) rather than ((arglist-cont-nonempty Y Z)) (the exact offsets may be different, I edited the comments after using C-c C-s to get the syntactic labels).

Does anybody know how one can fix this? I tried the newest version of CC-Mode (5.32.5) specifically downloaded from Sourceforge as well as the default versions coming with Debian and Ubuntu, but all of them get this wrong.

  • It seems like this has been fixed in a more recent versions of cc-mode (5.33). I'm not able to reproduce this running on: "GNU Emacs 25.0.50.3 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.23) of 2016-01-22". – Xaldew Feb 25 '16 at 11:33
  • @Xaldew Ah, yes, forgot to answer this. – Claudius Feb 26 '16 at 16:54
1

Download CC Mode 5.33 which is available at http://cc-mode.sourceforge.net/release.php. It solves this bug (amongst many others).

0

The fix is in upgrading to the newest version of cc-mode, which contains a bug fix for this issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.