GNU bug report logs - #24195
25.0.95; Wrong indentation after a 'less < than' comparison (c++-mode)

Previous Next

Packages: cc-mode, emacs;

Reported by: Arash <pbqbqp <at> gmail.com>

Date: Wed, 10 Aug 2016 15:40:01 UTC

Severity: minor

Tags: wontfix

Found in version 25.0.95

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Alan Mackenzie <acm <at> muc.de>
To: Arash <pbqbqp <at> gmail.com>
Cc: 24195 <at> debbugs.gnu.org
Subject: bug#24195: 25.0.95; Wrong indentation after a 'less < than' comparison (c++-mode)
Date: Thu, 11 Aug 2016 12:14:21 +0000
Hello, Arash.

On Wed, Aug 10, 2016 at 02:08:52PM +0430, Arash wrote:
> $ emacs -Q test.cc

> bool test()
> {
>     return \
>         a() <= b() &&
>         c() >= d() &&
>         e() == f() &&
>         g() != h() &&
>         i() >  j() &&
>         k() <  l() &&
              ^
>                m() == n() // !!!
>         ;
> }

Yes.  In the line "k() < l() &&", the "<" is being recognised as a
template opener.

The syntax of C++ is ambiguous, and it is difficult for anything which
isn't a compiler reliably to distinguish between "less than" and "open
template" in circumstances like that.  It was easier for earlier
versions of C++, where the "&&" operator wasn't valid inside a template.

I'm not sure I can do very much to help, here.  Even waiting on the
closing ">" before recognising a template wouldn't help much, because
you're just as likely to have the line with "<" before the line with
">".

There are crude workarounds, like writing "!(k() >= l()), but that's
horrible.

So, sorry and all that, I don't think I can do anything to fix this.

-- 
Alan Mackenzie (Nuremberg, Germany).




This bug report was last modified 5 years and 352 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.