Subject: Re: bug#22079: CC Mode 5.33 (C++/l); C++ cache inconsistency

From: Michael Welsh Duggan <[email-masked]>
Date: Fri, 04 Dec 2015 11:54:04 -0500

Alan Mackenzie <[email-masked]> writes:

> Hello, Michael.
>
> Thanks for another bug report.
>
> On Wed, Dec 02, 2015 at 11:28:00PM -0500, Michael Welsh Duggan wrote:

[...]

> I see you are using a relatively recent snapshot of the savannah master
> or emacs-25 branch (from ~26th November).
>
> The cause of the problem is not hard to track down.  On 11th November, I
> committed a fix "CC Mode: Respect users' settings of
> open-paren-in-column-0-is-defun-start.", which does precisely what it
> says.  Previously, I had bound open-paren-in-column-0-is-defun-start to
> nil around certain primitive calls for the sake of accurate scanning.
>
> The problem with binding o-p-i-c-0-i-d-s to nil is that it makes CC Mode
> very slow, particularly in big files, where continually scanning from
> the beginning of the file is sub-optimal.
>
> In the scenario you documented, we have ....
>
>
>
>> namespace std {                                    <=============== B
>> 
>> static_assert(ipfix::traits::is_same<uint8_t, unsigned char>,
>>               "Assumption that uint8_t is unsigned char is false");
>> 
>> template<>
>> struct char_traits<ipfix::traits::enable_if<
>>     ipfix::traits::is_signed<char>, unsigned char>>
>> {                                                  <=============== A
>>     typedef unsigned char                 char_type;
>>     typedef char_traits<char>::int_type   int_type;
>>     typedef char_traits<char>::off_type   off_type;
>>     typedef char_traits<char>::pos_type   pos_type;
>>     typedef char_traits<char>::state_type state_type;
>
> [ .... ]
>
> The actual top level (I think) is the brace at B.  CC Mode has, however,
> taken the brace at A (in column 0) to be a top level brace.
>
> This is a difficult problem to resolve satisfactorally, in general.
> What you could do is set open-paren-etc. to nil, or even set it to nil
> buffer locally for some files.  When I tried this on traits.hpp, it
> scanned without any parse state inconsistencies.

Indeed, the problem goes away with open-paren-in-column-0-is-defun-start
set to nil.  This is good, since the coding style my group uses includes
(innamespace . 0) in the c-offsets-alist.

-- 
Michael Welsh Duggan
([email-masked])