Subject: bug#56629: CC Mode 5.35.1 (C++//l); Cache state inconsistency

From: Alan Mackenzie <[email-masked]>
Date: Sun, 24 Jul 2022 15:28:56 +0000

Hello, Michael.

Thank you indeed for another bug report.

On Mon, Jul 18, 2022 at 10:42:16 -0400, Michael Welsh Duggan wrote:
> Package: cc-mode

> >From emacs -Q:

> Load the attached file (inline).  Turn on parse state debugging:

>     M-x c-toggle-parse-state-debug RET

> Navigate to the uint8_t:

>     C-s 8

> Delete the 8 and start to replace it:

>     <backspace> 1

> At this point I get a cache inconsistency warning:

> c-parse-state inconsistency at 179: using cache: nil, from scratch: (145).  POINT-MIN: 1
> Old state:
> (setq c-state-cache nil  c-state-cache-good-pos 81  c-state-nonlit-pos-cache nil  c-state-nonlit-pos-cache-limit 1  c-state-brace-pair-desert nil  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil  c-parse-state-point 179)

> This inconsistency has not yet caused incorrect editing behavior (that I
> have noticed, but I know that any cache problem has the possibility of
> causing problems down the line.

> class DataType :
>   public types::NamedType<std::uint16_t, struct DataTypeParam,
>                           types::EqComparable, types::Hashable>
> {
>   using base = types::NamedType<std::uint8_t, struct DataTypeParam,
>                                 types::EqComparable, types::Hashable>;
>  public:
>   using base::NamedType;
> 
> 
> };

The cause of this bug is the text properties put on the <s and >s.  These
are intended to be category properties in Emacs, but syntax-table
properties in XEmacs.  The mechanism which tests the presence of the
category property is chaotic in Emacs, though I think it works properly
in the standalone CC Mode; the detection is (wrongly) done both at
compile time and load time, and delivers different answers.  :-(

I will sort this out and let you know when it's done.

> Emacs  : GNU Emacs 29.0.50 (build 2, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0)
>  of 2022-07-15
> Package: CC Mode 5.35.1 (C++//l)
> Buffer Style: Pharos
> c-emacs-features: (pps-extended-state col-0-paren posix-char-classes gen-string-delim gen-comment-delim syntax-properties 1-bit)

[ .... ]

-- 
Alan Mackenzie (Nuremberg, Germany).