This is the mail archive of the gcc@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: gcc3 vs 176.gcc


Thinking about the kinds of bug reports we've seen about this,
I think we should classify things into three categories:

	float f;
	float *pf;

(1) Blatently wrong

	*(int *)&f	// warning: type-based aliasing violation

(2) Dangerous dereference

	*(int *)pf	// warning: possible type-based aliasing violation

(3) Dangerous cast

	(int *)pf	// warning: cast between incompatible types
	(void *)pf		// no warning
	(int *)(void *)pf	// no warning

The third should have a -W switch of its own and not be turned on
by -Wall, since I think that it would probably cause too many false
positives.  The first two probably should be implied by -Wall for
style reasons, much the same way as we warn for "if (x = y)".

There are still cases that we miss with this, but I think the vast
majority of the silliness will get caught.


r~


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