public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/31524]  New: prints incorrect warning
@ 2007-04-10  9:27 aldot at gcc dot gnu dot org
  2010-02-20 18:47 ` [Bug c/31524] " manu at gcc dot gnu dot org
  0 siblings, 1 reply; 2+ messages in thread
From: aldot at gcc dot gnu dot org @ 2007-04-10  9:27 UTC (permalink / raw)
  To: gcc-bugs

gcc >= 3.x emits wrong warning for assignment of bool=non-bool=value;

for bool=bool=value, no warning is emitted, which is fine.

$ for i in 2.95 3.4 4.0 4.1 4.2-HEAD 4.3-HEAD;do echo "# gcc-$i:";echo -e
"#include <stdbool.h>\nint i;bool b;int main(void){b=i=false;return b;}" |
gcc-$i -xc - -o boo -Wall;./boo ; echo ret=$?;done
# gcc-2.95:
ret=0
# gcc-3.4:
<stdin>: In function `main':
<stdin>:2: warning: suggest parentheses around assignment used as truth value
ret=0
# gcc-4.0:
<stdin>: In function 'main':
<stdin>:2: warning: suggest parentheses around assignment used as truth value
ret=0
# gcc-4.1:
<stdin>: In function 'main':
<stdin>:2: warning: suggest parentheses around assignment used as truth value
ret=0
# gcc-4.2-HEAD:
<stdin>: In function 'main':
<stdin>:2: warning: suggest parentheses around assignment used as truth value
ret=0
# gcc-4.3-HEAD:
<stdin>: In function 'main':
<stdin>:2: warning: suggest parentheses around assignment used as truth value
ret=0


-- 
           Summary: prints incorrect warning
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: aldot at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31524


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

* [Bug c/31524] prints incorrect warning
  2007-04-10  9:27 [Bug c/31524] New: prints incorrect warning aldot at gcc dot gnu dot org
@ 2010-02-20 18:47 ` manu at gcc dot gnu dot org
  0 siblings, 0 replies; 2+ messages in thread
From: manu at gcc dot gnu dot org @ 2010-02-20 18:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from manu at gcc dot gnu dot org  2010-02-20 18:47 -------
You are using an assignment as a truth value and that is a typical error when
ones confuses == with =, so we warn. Add parenthesis as the warning suggest
bool = (nobool = value) or silence the warning with the appropriate
-Wno-option.


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu dot org
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |WONTFIX


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31524


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

end of thread, other threads:[~2010-02-20 18:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-10  9:27 [Bug c/31524] New: prints incorrect warning aldot at gcc dot gnu dot org
2010-02-20 18:47 ` [Bug c/31524] " manu at gcc dot gnu dot org

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