Subject: Re: bug#11749: Acknowledgement (24.1; C-mode indentation gives wrong-type-argument error.)

From: Alan Mackenzie <[email-masked]>
Date: Sun, 2 Sep 2012 21:16:20 +0000

Hello, Kim.

On Wed, Aug 29, 2012 at 12:49:53AM +0200, Kim Storm wrote:
> M-x report-emacs-bug obviously refuses to include any useful information 
> -- so I send it through my Thunderbird client... this time.

> Tried 24.2 RC2 - and once again I hit this annoying indentation bug i c 
> mode:

> Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p 
> (5457 . 5720))
>    c-guess-basic-syntax()
>    c-indent-line()
>    indent-according-to-mode()
>    c-electric-paren(nil)
>    call-interactively(c-electric-paren nil nil)

> The offsets corresponds to a preceding { ... } block.

Yes.  It looks like the "state cache" (a cache of certain brace, paren
and bracket positions) has got corrupted.  This is difficult to make
repeatable, and is very dependent upon the exact navigation taken around
the C buffer.

> The code I was working on is the following (sorry, I cannot show more 
> than that):

>        if (!((xdom | xact | xobj | xxtr) & 0x80))
>      continue;

>        if (domains && !alldom && !((xdom | xobj | xxtr) & 0x01))
>      {

> I get a lot of errors -- making 24.2 impossible to work with for my C code.

> Here are some more backtraces:

> Debugger entered--Lisp error: (error "Invalid search bound (wrong side 
> of point)")
>    re-search-backward("^[     ]*:[     ]*\\(.\\)?" 5920 t)
>    c-lineup-gcc-asm-reg((arglist-cont-nonempty . 5920))
>    c-evaluate-offset(c-lineup-gcc-asm-reg (arglist-cont-nonempty 5920 
> 5950) arglist-cont-nonempty)
>    c-evaluate-offset((c-lineup-gcc-asm-reg c-lineup-arglist) 
> (arglist-cont-nonempty 5920 5950) arglist-cont-nonempty)
>    c-calc-offset((arglist-cont-nonempty 5920 5950))
>    c-get-syntactic-indentation(((arglist-cont-nonempty 5920 5950)))
>    c-indent-line()
>    indent-according-to-mode()
>    c-electric-paren(nil)
>    call-interactively(c-electric-paren nil nil)

That looks a bit like bug #10941, but isn't it.  It could be something
quite easy inside `c-lineup-gcc-asm-reg' (which I've not seen being used
before).  Is this an easily repeatable bug?  Any chance of a recipe?
Would you also dump your CC Mode configuration (C-c C-b) please.

> Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p 
> (5874 . 5881))
>    c-guess-basic-syntax()
>    c-indent-line()
>    indent-according-to-mode()
>    c-electric-paren(nil)
>    call-interactively(c-electric-paren nil nil)

> The last one came when I inserted the final ; in the last line of the 
> following snippet:

> static void add_hash_ext(idhash_t **hp, id_t *idtab, int n)
> {

>   }

>    static idhash_t *lookup_ext(idhash_t **hp, );

I've not been able to reproduce it in that limited context.  It looks
like another bug in the state cache, and they're bastards.

> Yes, there are syntax errors in that code -- but indentation should be 
> able to
> handle that without signalling errors all the time.

Yes.

> I have seen similar problems in 24.1 - but not in 23.4 that I usually
> use (for this very reason).

Might you have something unusual in your CC Mode config?

-- 
Alan Mackenzie (Nuremberg, Germany).