bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: as: undocumented evaluation of relational operators generates no syn


From: Nick Clifton
Subject: Re: as: undocumented evaluation of relational operators generates no syntax-err, but yields result -1 if true
Date: 12 Jun 2001 16:54:00 +0100
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

Hi Klaus,

> Problem :
> Relational operators are not defined in the documentation ("Using as"). 
> However, they are evaluated without generating a syntax-error :
> 
> Unfortunately, the result is -1 rather than 1, if the expression
> evaluates true.

Well this is just a feature rather than a bug.  Interestingly enough
the logical combiner operators (&& and ||) return 1 for true.  The use
of -1 for the comparison operators does appear to be an explicit
design feature however, so I do not intend to change it.
 
> as 2.9.1 for target 'i686-pc-linux-gnu' evaluates lines 14..18 in
> the same way, but fails on the more complicated expression in line
> 20 : 

This has been fixed in 2.11

> Therefore, I think this behavior is probably unintended.
> 
> Since some people might (if even unknowingly) rely on this feature, maybe
> just a warning could be issued if there are relational operators found in
> expressions .

Actually I think the easier thing to do would be to document the
behavior, so I am going to apply the patch below to do this.

Cheers
        Nick

Index: gas/doc/as.texinfo
===================================================================
RCS file: /cvs/src/src/gas/doc/as.texinfo,v
retrieving revision 1.39
diff -p -r1.39 as.texinfo
*** as.texinfo  2001/06/11 20:40:36     1.39
--- as.texinfo  2001/06/12 15:52:02
*************** Intermediate precedence
*** 3311,3317 ****
  @end table
  
  @item
! Lowest Precedence
  
  @table @code
  @cindex addition, permitted arguments
--- 3311,3317 ----
  @end table
  
  @item
! Low Precedence
  
  @table @code
  @cindex addition, permitted arguments
*************** result has the section of the left argum
*** 3331,3336 ****
--- 3331,3371 ----
  If both arguments are in the same section, the result is absolute.
  You may not subtract arguments from different sections.
  @c FIXME is there still something useful to say about undefined - undefined ?
+ 
+ @cindex comparison expressions
+ @cindex expressions, comparison
+ @item  ==
+ @dfn{Is Equal To}
+ @item <>
+ @dfn{Is Not Equal To}
+ @item <
+ @dfn{Is Less Than}
+ @itemx >
+ @dfn{Is Greater Than}
+ @itemx >=
+ @dfn{Is Greater Than Or Equal To}
+ @itemx <=
+ @dfn{Is Less Than Or Equal To}
+ 
+ The comparison operators can be used as infix operators.  A true results has a
+ value of -1 whereas a false result has a value of 0.   Note, these operators
+ perform signed comparisons.
+ @end table
+ 
+ @item Lowest Precedence
+ 
+ @table @code
+ @item &&
+ @dfn{Logical And}.
+ 
+ @item ||
+ @dfn{Logical Or}.
+ 
+ These two logical operations can be used to combine the results of sub
+ expressions.  Note, unlike the comparison operators a true result returns a
+ value of 1 but a false results does still return 0.  Also note that the 
logical
+ or operator has a slightly lower precedence than logical and.
+ 
  @end table
  @end enumerate
  





reply via email to

[Prev in Thread] Current Thread [Next in Thread]