This is the mail archive of the gcc-patches@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]

Re: [C++ Patch/RFC] PR 43906


On 08/04/2014 07:01 PM, Paolo Carlini wrote:
In fact I wondered about that a few minutes after sending my message...
And this is what I figured out: normally we have hard errors from
composite_pointer_type (eg, try scalar types, class types), even for
null values. The only exception I have been able to find earlier today
is that of pointer to the same function type, eg:

extern void z();
typedef void (*ptr)();
void i() { if ( z != (ptr)0 ); }

but in this case the C front-end too doesn't warn.

I don't see why we wouldn't want to warn in this case; it's still the case thet the comparison will always be false.

We can also see this situation for non-function pointers:

void f()
{
  int i;
  if (&i != (int*)0);
}

Jason


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