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, 27 Oct 2019 15:39:56 +0000

Hello, Eric.

On Thu, Oct 24, 2019 at 12:06:18 -0700, Eric Scrivner wrote:
> This seems related to (if not the same as) bug #5490.

> - This happens randomly and then randomly stops happening (cache expiry
> maybe?)
> - M-x revert-buffer does not fix.

Thanks for taking the trouble to report this bug, and thanks even more
for including so much information.

> Here's a snippet from the buffer at the time this happen, as you can see
> there seems to be a region until the end where everything becomes
> topmost-intro:

>       }                          // ((block-close 18328))
>                                 // ((statement 9560))
>       SDL_DestroyWindow(Window); // ((statement 9560))
>     }    // ((block-close 9490))
>     else                        // ((else-clause 9466))
>     {                                                             //
> ((substatement-open 18464))
>       PlatformLog("Failed to create window: %s", SDL_GetError()); //
> ((statement-block-intro 18473))
>     } // ((block-close 18473))
>                                 // ((topmost-intro 18576))
>                                 // ((topmost-intro 18576))
> SDL_Quit();                     // ((topmost-intro 18541))
>   }                             // ((topmost-intro 18548))
>   else                          // ((else-clause 9188))
>   {                             // ((substatement-open 18845))
>     PlatformLog("Failed to initialize SDL: %s", SDL_GetError()); //
> ((statement-block-intro 18901))((statement-block-intro 18724))
>   }                                                              //
> ((block-close 18901))
>                                 // ((topmost-intro 19093))
>   return EXIT_SUCCESS;          // ((topmost-intro 19093))
> }                               // ((topmost-intro 19242))

At the moment, all I can do is acknowledge receipt of your report.  It's
obviously not an easy bug to diagnose.

I can see two ways of making progress: (i) Inspecting
c-guess-basic-syntax, the function which analyses code and produces
(amongs other things) all these topmost-intro's.  It is essentially a
large cond form (Lisp's equivalent of a switch), and the single place
which produces topmost-intro comes fairly early on in this cond form;
(ii) Determine what aspects of a buffer do not get reinitialised after
evaluating M-x revert-buffer.  That could provide some clue.

[ CC Mode config dump acknowledged with thanks, but snipped ]

Just one thing.  If you haven't already done so, could you make a backup
copy of a buffer which triggers the bug, just in case after some future
edit it no longer does so.  Thanks!

-- 
Alan Mackenzie (Nuremberg, Germany).