Subject: bug#52340: Improper auto-indentation in C++-mode

From: Vince West <[email-masked]>
Date: Mon, 6 Dec 2021 16:09:32 -0600

`indent-region` is giving some weird results in c++-mode.  I will just
paste the main function here:

```C++
int main() {

  // looks good to me
  float nums[9] =
    {
      1., 2., 3.,
      4., 5., 6.,
      7., 8., 9.,
    };

  // wtf
  float * numsp = new float[9]
  {
    1., 2., 3.,
      4., 5., 6.,
      7., 8., 9.,
      };

}
```

In c-mode, the indentation looks fine:
```C
int main() {

  // looks good to me
  float nums[9] =
    {
      1., 2., 3.,
      4., 5., 6.,
      7., 8., 9.,
    };

  // looks fine in C-mode
  float * numsp = new float[9]
    {
      1., 2., 3.,
      4., 5., 6.,
      7., 8., 9.,
    };

}

```

In GNU Emacs 27.2 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60
Version 10.14.6 (Build 18G95))
 of 2021-03-27 built on builder10-14.porkrind.org
Windowing system distributor 'Apple', version 10.3.2022
System Description:  macOS 11.6.1

Recent messages:
Undo
Making completion list...
Indenting region... done
You can run the command ‘indent-region’ with C-M-\
Indenting region... done
previous-line: Beginning of buffer
Mark activated
Indenting region... done
previous-line: Beginning of buffer [2 times]
Making completion list... [2 times]

Configured using:
 'configure --with-ns '--enable-locallisppath=/Library/Application
 Support/Emacs/${version}/site-lisp:/Library/Application
 Support/Emacs/site-lisp' --with-modules'

Configured features:
NOTIFY KQUEUE ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS MODULES
THREADS JSON PDUMPER GMP

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: C++//l

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t
  abbrev-mode: t

Load-path shadows:
None found.

Features:
(shadow sort emacsbug sendmail mail-extr message rmc puny dired
dired-loaddefs format-spec rfc822 mml mml-sec password-cache epa derived
epg epg-config gnus-util rmail rmail-loaddefs text-property-search
time-date subr-x mm-decode mm-bodies mm-encode mail-parse rfc2231
rfc2047 rfc2045 mm-util ietf-drums mail-prsvr mailabbrev mail-utils
gmm-utils mailheader thingatpt cl-extra seq byte-opt gv bytecomp
byte-compile cconv help-mode novice cc-mode cc-fonts easymenu cc-guess
cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs
cl-loaddefs cl-lib tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel term/ns-win ns-win ucs-normalize mule-util
term/common-win tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch timer
select scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite charscript charprop case-table epa-hook
jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote threads kqueue cocoa ns multi-tty make-network-process emacs)

Memory information:
((conses 16 69710 8231)
 (symbols 48 8632 1)
 (strings 32 22129 1555)
 (string-bytes 1 831409)
 (vectors 16 13165)
 (vector-slots 8 160910 15816)
 (floats 8 31 31)
 (intervals 56 433 6)
 (buffers 1000 14))