Subject: bug#56256: closed (Re: bug#56256: Emacs 28.1 gets stuck when typing some C++ code)

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 02 Jul 2022 16:24:02 +0000

Your bug report

#56256: Emacs 28.1 gets stuck when typing some C++ code

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
56256: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=56256
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#56256: Emacs 28.1 gets stuck when typing some C++ code
From: Alan Mackenzie <[email-masked]>
To: Iru Cai <[email-masked]>
Cc: [email-masked], Lars Ingebrigtsen <[email-masked]>, [email-masked]
Date: Sat, 2 Jul 2022 16:23:15 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello, Iru.

On Wed, Jun 29, 2022 at 11:03:47 +0800, Iru Cai wrote:

> On 2022/6/29 00:28, Alan Mackenzie wrote:
> > I think the following patch should fix it.  Could you try it out on your
> > real C++ code, please, and tell us whether the bug is actually fixed.
> > (If you want any help with applying the patch or byte compiling CC Mode
> > afterwards, feel free to send me private email.):

> Thanks, this fixes this bug, and I haven't found a issue when editing 
> some of my C++ code.

[ .... ]

Thanks for the testing!

I've committed the patch to the release branch of our git tree, and I'm
closing the bug with this post.

-- 
Alan Mackenzie (Nuremberg, Germany).

Subject: Emacs 28.1 gets stuck when typing some C++ code
From: Iru Cai <[email-masked]>
To: [email-masked]
Date: Mon, 27 Jun 2022 18:22:15 +0800
List-Id: <debbugs-submit.debbugs.gnu.org>

Emacs gets stuck when trying to type the '&' character at the end of the 
buffer when there's the following code in C++ mode (this code is from 
https://www.gingerbill.org/article/2015/08/19/defer-in-cpp/):

```

template <typename F>
struct privDefer {
     F f;
     privDefer(F f) : f(f) {}
     ~privDefer() { f(); }
};

template <typename F>
privDefer<F> defer_func(F f) {
     return privDefer<F>(f);
}

#define DEFER_1(x, y) x##y
#define DEFER_2(x, y) DEFER_1(x, y)
#define DEFER_3(x)    DEFER_2(x, __COUNTER__)
#define defer(code) auto DEFER_3(_defer_) = defer_func([

```

Steps to reproduce:

1. create a C++ source file with this code and open it with Emacs, if 
the file doesn't have a C++ source suffix, enable c++mode

2. type the '&' symbol at the last line after "defer_func(["

3. then Emacs gets stuck

I can see this bug in Emacs 28.1 and git revision 
5b1bb1af030597aab7f7895b6e3da9b430f9438a. I've also tried ``emacs -Q`` 
and ``emacs -Q -nw``, the bug still exists.