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: module level flags


Joe Buck <Joe.Buck@synopsys.com> writes:

> There is an argument for attempting to detect obvious cases of error, and
> this would help users.  Some developers have objected that because not all
> errors can be detected, this would give users a false sense of security
> when they don't see any aliasing warnings.

No-one has objected to someone adding a flag that detects certain
"obvious" cases of violating the aliasing rules.  At least one patch
was posted in 1999 by Zack, but it never quite worked well enough to
go in the tree.

In fact, I believe there was some consensus that it's even OK to warn
about such constructs as:

double *dp;
int *ip = (int *)dp;

even though that's not an immediate problem, since it is at least very
suspicious.  The flag would not be on by default, of course.

Amusingly, it used to be that GCC had lots of constructs like that,
but I think I've cleaned up many of them as part of the new GC work.


I think that generally, such warnings are helpful even if they aren't
100% perfect.  The usual reason such errors are introduced into
programs are not that the programmer made a mistake in applying the
appropriate rule, it's that the programmer wasn't aware that the rule
existed.  Thus, the warnings help to educate programmers, and
hopefully they will be educated enough that they don't make the
mistakes that the compiler can't catch.

-- 
- Geoffrey Keating <geoffk@geoffk.org>


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