Re: comparing function pointer with int does not produce error
On Tue, Oct 23, 2001 at 08:21:26PM +0200, Martin v. Loewis wrote:
> > The following code does not produce an error when one is expected.
> > void stat ();
> >
> > static const int success = 0;
> >
> > void monk ()
> > {
> > if (stat == success);
> > };
>
> Thanks for your report. This is not a bug in the compiler: both the
> function pointer and the integer convert to bool (4.12). So this is a
> boolean comparison, and thus well-formed C++.
Really?
drow@nevyn:~% cat test.cc
void stat ();
static const int bar = 1;
int
main()
{
if (bar == stat) return 4;
}
drow@nevyn:~% g++-3.0 test.cc
test.cc: In function `int main()':
test.cc:6: ISO C++ forbids comparison between pointer and integer
--
Daniel Jacobowitz Carnegie Mellon University
MontaVista Software Debian GNU/Linux Developer
Reply to: