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] |
Hi, On 08/05/2014 03:58 AM, Jason Merrill wrote:
In general, I agree of course. I was trying to understand if keeping the issue as minimally one of consistency with the C front-end simplified it.On 08/04/2014 07:01 PM, Paolo Carlini wrote: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.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.
Sure. Then, however, we must be careful about the actual pointer types, otherwise we change hard errors to warnings. And void* is an exception to the general rule. I tried using ptr_reasonably_similar to avoid the explicit call of comptypes + separate VOID_TYPE_P, but unfortunately it appears too loose about at least pointers to function types.We can also see this situation for non-function pointers: void f() { int i; if (&i != (int*)0); }
Thanks! Paolo. //////////////////////////
Attachment:
patch_43906_3
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |