This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/10170] No warning for "if(foo)" instead of "if(foo())"


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]