gcc3 vs 176.gcc

Joe Buck jbuck@synopsys.COM
Thu Jan 10 13:00:00 GMT 2002


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

I like it.

> 	float f;
> 	float *pf;
> 
> (1) Blatently wrong
> 
> 	*(int *)&f	// warning: type-based aliasing violation

Maybe this one should be a hard error if -fstrict-aliasing is enabled
and optimization is on, as bad code is so highly likely.  But there
is perhaps a philosophical problem with having a warning become an
error based on optimization level.

> (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 last one is still dangerous, though possibly slightly harder to
detect.  Also, (2) contains (3), so avoiding double warnings might
be slightly tricky.

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

Wow.  Maybe we'll finally make some progress on this.



More information about the Gcc mailing list