public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Precedence of GNU C++ extensions >? and <? (min/max operators)
@ 2011-03-05 10:07 Jeremy Hall
  2011-03-05 15:51 ` Axel Freyn
  2011-03-05 16:27 ` Bob Plantz
  0 siblings, 2 replies; 4+ messages in thread
From: Jeremy Hall @ 2011-03-05 10:07 UTC (permalink / raw)
  To: gcc-help

Hi,

Does anyone know the exact priority of these operators?  Its not
mentioned in the
description of the extension as far as I can see.

Thanks
Jeremy

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

* Re: Precedence of GNU C++ extensions >? and <? (min/max operators)
  2011-03-05 10:07 Precedence of GNU C++ extensions >? and <? (min/max operators) Jeremy Hall
@ 2011-03-05 15:51 ` Axel Freyn
  2011-03-05 16:27 ` Bob Plantz
  1 sibling, 0 replies; 4+ messages in thread
From: Axel Freyn @ 2011-03-05 15:51 UTC (permalink / raw)
  To: gcc-help

Hi Jeremy,

On Sat, Mar 05, 2011 at 10:07:01AM +0000, Jeremy Hall wrote:
> Does anyone know the exact priority of these operators?  Its not
> mentioned in the description of the extension as far as I can see.
As I read the documentation in the gcc-sourcecode, they are the same
precedence as "<", ">", "<=", ">=". They are relation operators and
form a "relational-expression": (§5.9 in C++ standard, [expr.rel])

See line 6258-6296 in
http://gcc.gnu.org/viewcvs/branches/gcc-4_5-branch/gcc/cp/parser.c?view=markup&revision=170622
relational-expression:
  shift-expression
  relational-expression < shift-expression
  relational-expression > shift-expression
  relational-expression <= shift-expression
  relational-expression >= shift-expression

GNU Extension:

relational-expression:
  relational-expression <? shift-expression
  relational-expression >? shift-expression 


HTH,

Axel

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

* Re: Precedence of GNU C++ extensions >? and <? (min/max operators)
  2011-03-05 10:07 Precedence of GNU C++ extensions >? and <? (min/max operators) Jeremy Hall
  2011-03-05 15:51 ` Axel Freyn
@ 2011-03-05 16:27 ` Bob Plantz
  1 sibling, 0 replies; 4+ messages in thread
From: Bob Plantz @ 2011-03-05 16:27 UTC (permalink / raw)
  To: Jeremy Hall; +Cc: gcc-help

On 3/5/2011 2:07 AM, Jeremy Hall wrote:
> Hi,
>
> Does anyone know the exact priority of these operators?  Its not
> mentioned in the
> description of the extension as far as I can see.
>
> Thanks
> Jeremy
I always told my students that multiplication and division have
higher precedence than addition and subtraction. Use
parentheses everyplace else. Code readability was part of
their grade in my classes.

--Bob


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

* Re: Precedence of GNU C++ extensions >? and <? (min/max operators)
@ 2011-03-05 17:38 Jeremy Hall
  0 siblings, 0 replies; 4+ messages in thread
From: Jeremy Hall @ 2011-03-05 17:38 UTC (permalink / raw)
  To: gcc-help

Thanks for looking this up Axel,
Exactly the info I needed.
(I am writing an arithmetic expression interpreter).

Regards
Jeremy

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

end of thread, other threads:[~2011-03-05 17:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-05 10:07 Precedence of GNU C++ extensions >? and <? (min/max operators) Jeremy Hall
2011-03-05 15:51 ` Axel Freyn
2011-03-05 16:27 ` Bob Plantz
2011-03-05 17:38 Jeremy Hall

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).