This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/10170] No warning for "if(foo)" instead of "if(foo())"
- From: "bangerth at dealii dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 19 Jul 2003 02:23:26 -0000
- Subject: [Bug c/10170] No warning for "if(foo)" instead of "if(foo())"
- References: <20030320182600.10170.xkinh@yahoo.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10170
bangerth at dealii dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |gdr at gcc dot gnu dot org
Status|RESOLVED |REOPENED
Resolution|WONTFIX |
------- Additional Comments From bangerth at dealii dot org 2003-07-19 02:23 -------
Gaby, I think you misunderstood the intent of the PR: this is not about the case
where the condition is constant, but where the condition should read
if (foo())
(note the function call) and is misspelled as
if (foo)
In that case, standard C implies that the expression "foo" decays to a pointer
to function which is subsequently compared to zero. Since the code is only legal
if foo is a declared function, the comparison always returns true. Since
writing such code is nonsensical, it is certainly not a widespread idiom,
but something worth warning about.
I'll reopen the PR -- if you still feel the same way, feel free to close
it again.
W.