Subject: Re: bug#36484: c-mode hangs on macro with comment

From: Alan Mackenzie <[email-masked]>
Date: 4 Jul 2019 10:36:20 -0000

Hello, Nicholas.

In article <[email-masked]> you wrote:
> Here's a simple C program:

> #define x /***/5
> int main(void) {
>     return x;
> }

> `gcc -Wall` compiles it without any warnings, but opening it causes
> Emacs to hang, and sometimes even to freeze hard.

I can reproduce this, and I'm looking into the cause.

> It has something to do with the macro, but I haven't been able to
> figure out exactly what's going on.

> Here's a test function with an even smaller reproducing example:

> (defun c-mode-hang ()
>   (interactive)
>   (with-temp-buffer
>     (insert "#define /***/5")
>     (c-mode)))

> Running that function under the profiler suggests that the problem is
> in `c-end-of-macro`:

> - c-extend-region-for-CPP          13869  98%
>   - c-end-of-macro                     10470  74%
>     c-forward-single-comment        2759  19%

Thanks, that's helpful information.

> This may have something to do with commit 39acaf, or maybe 6b5388.

> GNU Emacs 27.0.50 (build 6, x86_64-pc-linux-gnu, GTK+ Version 3.22.30)
> of 2019-06-30

-- 
Alan Mackenzie (Nuremberg, Germany).