public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* Newbie: C++ Frontend Lexical Analysis Issue, <::abs(n) does not parse
@ 2004-03-27 15:20 Thierry Moreau
  2004-03-27 17:53 ` Alexandre Oliva
  2004-03-27 23:35 ` Zack Weinberg
  0 siblings, 2 replies; 5+ messages in thread
From: Thierry Moreau @ 2004-03-27 15:20 UTC (permalink / raw)
  To: gcc-bugs

The following sample fails to compile by GCC, and I am surprised:

===========================
// sample.cpp
int abs(int x)
{    return (x>=0)?x:-x; }

class A {
  protected:
    int m,n;
  public:
    int g(void);
    int h(void);
};

int A::g(void)
{    return ::abs(m) < ::abs(n); }

int A::h(void)
{    return ::abs(m)<::abs(n); } /* parse error here (!) */
===========================

Obviously, there is a simple work-around.

Please excuse my reluctance to file an official bug report in another problem reporting service.

Again and again, many many thanks to all those who brings the GCC technology to life!
 
-- 

- Thierry Moreau

CONNOTECH Experts-conseils inc.
9130 Place de Montgolfier
Montreal, Qc
H2M 2A1

Tel.: (514)385-5691
Fax:  (514)385-5900

web site: http://www.connotech.com
e-mail: thierry.moreau@connotech.com



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Newbie: C++ Frontend Lexical Analysis Issue, <::abs(n) does not parse
  2004-03-27 15:20 Newbie: C++ Frontend Lexical Analysis Issue, <::abs(n) does not parse Thierry Moreau
@ 2004-03-27 17:53 ` Alexandre Oliva
  2004-03-27 23:35 ` Zack Weinberg
  1 sibling, 0 replies; 5+ messages in thread
From: Alexandre Oliva @ 2004-03-27 17:53 UTC (permalink / raw)
  To: Thierry Moreau; +Cc: gcc-bugs

On Mar 27, 2004, Thierry Moreau <thierry.moreau@connotech.com> wrote:

> {    return ::abs(m)<::abs(n); } /* parse error here (!) */
                      ^^ this is a digraph for `[' IIRC

-- 
Alexandre Oliva             http://www.ic.unicamp.br/~oliva/
Red Hat Compiler Engineer   aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist  oliva@{lsd.ic.unicamp.br, gnu.org}


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Newbie: C++ Frontend Lexical Analysis Issue, <::abs(n) does not parse
  2004-03-27 15:20 Newbie: C++ Frontend Lexical Analysis Issue, <::abs(n) does not parse Thierry Moreau
  2004-03-27 17:53 ` Alexandre Oliva
@ 2004-03-27 23:35 ` Zack Weinberg
  2004-03-29 15:58   ` Thierry Moreau
  1 sibling, 1 reply; 5+ messages in thread
From: Zack Weinberg @ 2004-03-27 23:35 UTC (permalink / raw)
  To: Thierry Moreau; +Cc: gcc-bugs

Thierry Moreau <thierry.moreau@connotech.com> writes:

> The following sample fails to compile by GCC, and I am surprised:

...
> {    return ::abs(m)<::abs(n); } /* parse error here (!) */

When the two characters <: appear next to each other like this, it is
taken as an alternate spelling ("digraph") for a [ token.  The point
of this is to make it easier to write C on the (rare) platforms which
do not have an [ character.  This is an awkward feature but the
language standard requires it.

Inserting a space is the correct fix.

> Please excuse my reluctance to file an official bug report in
> another problem reporting service.

Huh?  Is there a problem with our bug tracking system?

zw


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Newbie: C++ Frontend Lexical Analysis Issue, <::abs(n) does not parse
  2004-03-27 23:35 ` Zack Weinberg
@ 2004-03-29 15:58   ` Thierry Moreau
  2004-03-29 16:49     ` Zack Weinberg
  0 siblings, 1 reply; 5+ messages in thread
From: Thierry Moreau @ 2004-03-29 15:58 UTC (permalink / raw)
  To: Zack Weinberg; +Cc: gcc-bugs



Zack Weinberg wrote:

>Thierry Moreau <thierry.moreau@connotech.com> writes:
>
>  
>
>>The following sample fails to compile by GCC, and I am surprised:
>>    
>>
>
>...
>  
>
>>{    return ::abs(m)<::abs(n); } /* parse error here (!) */
>>    
>>
>
>When the two characters <: appear next to each other like this, it is
>taken as an alternate spelling ("digraph") for a [ token.  The point
>of this is to make it easier to write C on the (rare) platforms which
>do not have an [ character.  This is an awkward feature but the
>language standard requires it.
>
>Inserting a space is the correct fix.
>  
>
Agreed, thanks for your explanation.

>>Please excuse my reluctance to file an official bug report in
>>another problem reporting service.
>>    
>>
>
>Huh?  Is there a problem with our bug tracking system?
>  
>
No,  I just was not shure if it was a bug in the first  place, and I 
wanted someone more knowledgeable to file an official bug report if need be.

I certainly didn't intend to fill a *bug* report while I was to learn 
that the digraph feature is part of the C language definition since the 
first amendment to ANSI C:1989 (I somehow antcipated some valid explanation)

Regards,

-- 

- Thierry Moreau

CONNOTECH Experts-conseils inc.
9130 Place de Montgolfier
Montreal, Qc
H2M 2A1

Tel.: (514)385-5691
Fax:  (514)385-5900

web site: http://www.connotech.com
e-mail: thierry.moreau@connotech.com



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Newbie: C++ Frontend Lexical Analysis Issue, <::abs(n) does not parse
  2004-03-29 15:58   ` Thierry Moreau
@ 2004-03-29 16:49     ` Zack Weinberg
  0 siblings, 0 replies; 5+ messages in thread
From: Zack Weinberg @ 2004-03-29 16:49 UTC (permalink / raw)
  To: Thierry Moreau; +Cc: gcc-bugs

Thierry Moreau <thierry.moreau@connotech.com> writes:
> No,  I just was not shure if it was a bug in the first  place, and I
> wanted someone more knowledgeable to file an official bug report if
> need be.

That's fine.  But filing an official bug report would have been fine
too.  We don't mind getting the occasional non-bug reported.

zw


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-03-29 16:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-27 15:20 Newbie: C++ Frontend Lexical Analysis Issue, <::abs(n) does not parse Thierry Moreau
2004-03-27 17:53 ` Alexandre Oliva
2004-03-27 23:35 ` Zack Weinberg
2004-03-29 15:58   ` Thierry Moreau
2004-03-29 16:49     ` Zack Weinberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).