Subject: bug#37910: CC Mode 5.33.2 (C++//l); CC-mode inconsistently indents everything as topmost-intro after a while

From: Alan Mackenzie <[email-masked]>
Date: Sun, 10 Nov 2019 19:02:54 +0000

Hello, Eric.

On Sun, Nov 10, 2019 at 09:47:35 -0800, Eric Scrivner wrote:
> I've applied the patch and run emacs with it. Unfortunately, it doesn't
> seem to solve the issue.

That's a pity.  But I think I will commit that patch anyway, since it is
an accident waiting to happen if I don't.

> On the bright side, I believe I had buffers which can reliably
> reproduce the issue (at least locally).

THAT'S ABSOLUTELY BRILLIANT!!!  :-)

> I've copied one such file below. The issue can be reproduced by simply
> going to the end of `main` and attempting to indent the `SQL_Quit()`
> statement. At first it attempts to overindent the line as
> `statement-cont`, then if I go up and attempt to indent the
> `PlatformLog` in the else statement then return to the SDL_Quit and
> indent it, it has become `topmost-intro`.  Apologies for the long
> length of the file, but hopefully it can help with reproduction:

No need for any apology whatsoever.  I can indeed reproduce the bug.

I was right, in that the bug is in the c-state-cache mechanism.  As you
mentioned in your other post, the bug is triggered by C++ raw strings.
When I had a look at some CC Mode debugging output, it was apparent that
some of the braces inside a raw string had been recorded as brace
positions, which is clearly wrong.

So this bug, which was up till recently unreproducible, is now just a
matter of (tedious) debugging.  That's a tremendous advance!  If we were
on the same continent, I'd ask you over for a drink!

Have a great Sunday afternoon!

[ .... ]

--
Alan Mackenzie (Nuremberg, Germany).