Linux and aliasing?

Jason Merrill jason@cygnus.com
Mon Jun 7 02:14:00 GMT 1999


>>>>> Martin v Loewis <martin@mira.isdn.cs.tu-berlin.de> writes:

 > We don't really emit *bad* code: garbage in, garbage out. People will
 > run into problems, yes. We will advertise this new feature in big
 > letters, and people will recompile with -fno-strict-aliasing, and then
 > see whether it still breaks (for some other reason). If it was an
 > aliasing problem, we can tell them that their code was not C.

My problem with this is that only people who read the release notes for
*this release* will see the big letters.  Meanwhile, people who start with
a later version or aren't involved in deploying the tools or whatever won't
see the warning.  Meanwhile, casts are an intuitive way to achieve the
desired effect, much more obvious than unions, so people who haven't been
explicitly warned will continue to write code that uses unsafe casts,
without realizing that it will break.

Saying "garbage in, garbage out" is a cop-out.  If we're going to let code
like this break, we need to emit a warning so that people know that they
have a problem, rather than leaving them to debug obscure problems.

BTW, the union trick isn't part of C, either.  It's a GCC implementation
choice.

Jason


More information about the Gcc mailing list