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



------- Additional Comments From xkinh at yahoo dot com  2003-07-19 15:17 -------
Subject: Re:  No warning for "if(foo)" instead of "if(foo())"

There is no question about right or wrong or how to do
it.  I just hope the GCC compiler, if it's possible,
will give a warning message as other compilers do, so
users could see their mistakes.  This warning is the
same warning of :
  if ( a_number = another_number) 
     .....
  instead of 
  if ( a_number == another_number)
     .....

The more user friendly a compiler provides, the more
users love and use it.  
thanks,
Kinh

--- gdr at integrable-solutions dot net
<gcc-bugzilla@gcc.gnu.org> wrote:
> 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
> 
> 
> 
> ------- Additional Comments From gdr at
> integrable-solutions dot net  2003-07-19 08:42
> -------
> Subject: Re:  No warning for "if(foo)" instead of
> "if(foo())"
> 
> "bangerth at dealii dot org"
> <gcc-bugzilla@gcc.gnu.org> writes:
> 
> | Gaby, I think you misunderstood the intent of the
> PR: this is not about the case
> 
> No, I don't think I misunderstood.
> 
> | where the condition is constant, but where the
> condition should read
> |   if (foo())
> | (note the function call) and is misspelled as
> |   if (foo)
> 
> I understood that.  That is what I explained in the
> audit trail.
> 
> | 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.
> 
> Not really. Again see the audit trail.  Also, see
> glibc source code.
> 
> -- Gaby
> 
> 
> 
> 
> ------- You are receiving this mail because: -------
> You reported the bug, or are watching the reporter.
> You are on the CC list for the bug, or are watching
> someone who is.


__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com


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