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.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 24195 in the body.
You can then email your comments to 24195 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#24195; Package emacs. (Wed, 10 Aug 2016 15:40:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Arash <pbqbqp <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 10 Aug 2016 15:40:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Arash <pbqbqp <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 25.0.95; Wrong indentation after a 'less < than' comparison (c++-mode)
Date: Wed, 10 Aug 2016 14:08:52 +0430
$ emacs -Q test.cc

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




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#24195; Package emacs,cc-mode. (Wed, 10 Aug 2016 22:08:01 GMT) Full text and rfc822 format available.

Message #8 received at 24195 <at> debbugs.gnu.org (full text, mbox):

From: Robert Cochran <robert-emacs <at> cochranmail.com>
To: Arash <pbqbqp <at> gmail.com>
Cc: 24195 <at> debbugs.gnu.org
Subject: Re: bug#24195: 25.0.95;
 Wrong indentation after a 'less < than' comparison (c++-mode)
Date: Wed, 10 Aug 2016 15:07:19 -0700
I can comfirm; error is still present on emacs-25 branch @ commit f785ff4
-- 
~Robert Cochran

GPG Fingerprint - E778 2DD4 FEA6 6A68 6F26  AD2D E5C3 EB36 4886 8871




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#24195; Package emacs,cc-mode. (Thu, 11 Aug 2016 12:15:01 GMT) Full text and rfc822 format available.

Message #11 received at 24195 <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: Arash <pbqbqp <at> gmail.com>
Cc: 24195 <at> debbugs.gnu.org
Subject: Re: 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).




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#24195; Package emacs,cc-mode. (Fri, 12 Aug 2016 15:27:01 GMT) Full text and rfc822 format available.

Message #14 received at 24195 <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> users.sourceforge.net>
To: Alan Mackenzie <acm <at> muc.de>
Cc: Arash <pbqbqp <at> gmail.com>, 24195 <at> debbugs.gnu.org
Subject: Re: bug#24195: 25.0.95; Wrong indentation after a 'less < than'
 comparison (c++-mode)
Date: Fri, 12 Aug 2016 11:26:33 -0400
On Thu, Aug 11, 2016 at 8:14 AM, Alan Mackenzie <acm <at> muc.de> wrote:
> Yes.  In the line "k() < l() &&", the "<" is being recognised as a
> template opener.

Is it possible to say that "<" can't be a template opener when it
comes after a close paren? (I can't think of a case in C++ where that
would fail, though I'm not 100% certain there isn't one)




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#24195; Package emacs,cc-mode. (Fri, 12 Aug 2016 16:57:02 GMT) Full text and rfc822 format available.

Message #17 received at 24195 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: Noam Postavsky <npostavs <at> users.sourceforge.net>
Cc: Alan Mackenzie <acm <at> muc.de>, Arash <pbqbqp <at> gmail.com>,
 24195 <at> debbugs.gnu.org
Subject: Re: bug#24195: 25.0.95;
 Wrong indentation after a 'less < than' comparison (c++-mode)
Date: Fri, 12 Aug 2016 18:56:05 +0200
On Aug 12 2016, Noam Postavsky <npostavs <at> users.sourceforge.net> wrote:

> On Thu, Aug 11, 2016 at 8:14 AM, Alan Mackenzie <acm <at> muc.de> wrote:
>> Yes.  In the line "k() < l() &&", the "<" is being recognised as a
>> template opener.
>
> Is it possible to say that "<" can't be a template opener when it
> comes after a close paren? (I can't think of a case in C++ where that
> would fail, though I'm not 100% certain there isn't one)

operator()<foo>

Andreas.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#24195; Package emacs,cc-mode. (Thu, 18 Aug 2016 12:12:01 GMT) Full text and rfc822 format available.

Message #20 received at 24195 <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: Andreas Schwab <schwab <at> linux-m68k.org>
Cc: Alan Mackenzie <acm <at> muc.de>, Arash <pbqbqp <at> gmail.com>,
 24195 <at> debbugs.gnu.org
Subject: Re: bug#24195: 25.0.95;
 Wrong indentation after a 'less < than' comparison (c++-mode)
Date: Thu, 18 Aug 2016 08:11:26 -0400
Andreas Schwab <schwab <at> linux-m68k.org> writes:

> On Aug 12 2016, Noam Postavsky <npostavs <at> users.sourceforge.net> wrote:
>
>> On Thu, Aug 11, 2016 at 8:14 AM, Alan Mackenzie <acm <at> muc.de> wrote:
>>> Yes.  In the line "k() < l() &&", the "<" is being recognised as a
>>> template opener.
>>
>> Is it possible to say that "<" can't be a template opener when it
>> comes after a close paren? (I can't think of a case in C++ where that
>> would fail, though I'm not 100% certain there isn't one)
>
> operator()<foo>

So could we say "<" can't be a template opener when it comes after a
close paren except for the close paren of "operator()"?




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#24195; Package emacs,cc-mode. (Mon, 22 Aug 2016 11:09:01 GMT) Full text and rfc822 format available.

Message #23 received at 24195 <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: npostavs <at> users.sourceforge.net
Cc: Arash <pbqbqp <at> gmail.com>, Andreas Schwab <schwab <at> linux-m68k.org>,
 24195 <at> debbugs.gnu.org
Subject: Re: bug#24195: 25.0.95; Wrong indentation after a 'less < than'
 comparison (c++-mode)
Date: Mon, 22 Aug 2016 11:08:02 +0000
Hello, Noam.

On Thu, Aug 18, 2016 at 08:11:26AM -0400, npostavs <at> users.sourceforge.net wrote:
> Andreas Schwab <schwab <at> linux-m68k.org> writes:

> > On Aug 12 2016, Noam Postavsky <npostavs <at> users.sourceforge.net> wrote:

> >> On Thu, Aug 11, 2016 at 8:14 AM, Alan Mackenzie <acm <at> muc.de> wrote:
> >>> Yes.  In the line "k() < l() &&", the "<" is being recognised as a
> >>> template opener.

> >> Is it possible to say that "<" can't be a template opener when it
> >> comes after a close paren? (I can't think of a case in C++ where that
> >> would fail, though I'm not 100% certain there isn't one)

> > operator()<foo>

> So could we say "<" can't be a template opener when it comes after a
> close paren except for the close paren of "operator()"?

We could, but I can't see it helping very much (though it might help a
little bit).

There are probably quite a lot of special cases like that where it is
possible to say for sure that the "<" does/doesn't introduce a template
construct.  But that will leave a lot of ambiguous cases.  The more we
try to analyse these, the closer we get to building a compiler inside CC
Mode.  For example, the example given might have been "k < l() && ....",
leaving no syntactic clues about the templateicity of "<".

Analysing the C++ syntax to determine these determinable cases would be
a lot of work, and it would be a lot of work to implement it, too.

The C++ standards people haven't thought it worthwhile to preserve
unambigious syntax in their language, so there is no way CC Mode can get
it right every time.

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#24195; Package emacs,cc-mode. (Thu, 25 Aug 2016 01:25:02 GMT) Full text and rfc822 format available.

Message #26 received at 24195 <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: Alan Mackenzie <acm <at> muc.de>
Cc: Arash <pbqbqp <at> gmail.com>, Andreas Schwab <schwab <at> linux-m68k.org>,
 24195 <at> debbugs.gnu.org
Subject: Re: bug#24195: 25.0.95;
 Wrong indentation after a 'less < than' comparison (c++-mode)
Date: Wed, 24 Aug 2016 21:24:43 -0400
tags 24195 wontfix
quit

Alan Mackenzie <acm <at> muc.de> writes:

>> So could we say "<" can't be a template opener when it comes after a
>> close paren except for the close paren of "operator()"?
>
> We could, but I can't see it helping very much (though it might help a
> little bit).
>
> There are probably quite a lot of special cases like that where it is
> possible to say for sure that the "<" does/doesn't introduce a template
> construct.  But that will leave a lot of ambiguous cases.  The more we
> try to analyse these, the closer we get to building a compiler inside CC
> Mode.  For example, the example given might have been "k < l() && ....",
> leaving no syntactic clues about the templateicity of "<".
>
> Analysing the C++ syntax to determine these determinable cases would be
> a lot of work, and it would be a lot of work to implement it, too.
>
> The C++ standards people haven't thought it worthwhile to preserve
> unambigious syntax in their language, so there is no way CC Mode can get
> it right every time.

Makes sense, I've been out of C++ for some time, so I kind of forgot how
ridiculous the syntax is.  Marking as wontfix.




Added tag(s) wontfix. Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Thu, 25 Aug 2016 01:25:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 24195 <at> debbugs.gnu.org and Arash <pbqbqp <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 03 Aug 2019 20:44:01 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 01 Sep 2019 11:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 231 days ago.

Previous Next


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