warning: suggest parenthesis around assignment used as truth value

Ben Abbott bpabbott at mac.com
Fri Mar 13 09:33:22 CDT 2009


On Mar 13, 2009, at 10:20 PM, John W. Eaton wrote:

> On 13-Mar-2009, Ben Abbott wrote:
>
> | On Mar 13, 2009, at 3:38 PM, John W. Eaton wrote:
> |
> | > On 13-Mar-2009, Ben Abbott wrote:
> | >
> | > | On Mar 13, 2009, at 9:40 AM, Rob Mahurin wrote:
> | > |
> | > | > On Mar 12, 2009, at 9:08 PM, Ben Abbott wrote:
> | > | >> Can someone explain what this warning is intended to imply?
> | > | >>
> | > | >> 	warning: suggest parenthesis around assignment used as truth
> | > value
> | > | >
> | > | > This is a gcc warning? The idiom
> | > | > 	if (x=1) { ... }
> | > | > is legal and useful but often a typo for
> | > | > 	if (x==1) { ... }
> | > | > Extra parentheses
> | > | > 	if ((x=1)) { ... }
> | > | > apparently suppress the warning.
> | >
> | > The intent of the Octave warning is the same as the GCC  
> warning.  In
> | > what case is it emitted incorrectly?
> | >
> | > | Your examples do give me some additional context for what is  
> imlied.
> | > | Unfortunately, I've searched my sources and don't see such an
> | > instance
> | > | in my if/elseif statments. Further when I convert warnings to  
> errors
> | > | ("warning error"), I get what looks like a parser error.
> | >
> | > Using "warning error" will likely generate a lot of unwanted  
> errors
> | > from code that is distributed with Octave.  We should probably  
> limit
> | > these warnings to code that is not part of Octave itself.
> | >
> | > jwe
> |
> | I'm still getting the original warning. Can anyone recommend what I
> | might do to determine the respective file and line number which is
> | responsible?
>
> I should have a change checked in shortly that will give you a line
> number and a filename for this parser warning.  I've also checked in
> another change that should make
>
>  warning on backtrace
>
> work again.  But that is no help here, since the warning you are
> seeing is emitted when Octave is parsing an expression, not when it is
> evaluating it.
>
> jwe

Great! ... I'll delay my frustrations of looking for this until  
later ;-)

Thanks
Ben



More information about the Octave-maintainers mailing list