From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Marcel Cox" To: Bernd Schmidt Cc: gcc AT gcc.gnu.org, jbuck AT synopsys.COM, rms AT gnu.org Subject: Re: type based aliasing again Date: Tue, 14 Sep 1999 07:14:00 -0000 Message-id: <37DE5830.EC1FAE36@cie.etat.lu> References: X-SW-Source: 1999-09/msg00534.html I know this does not proof it is safe. The fact however that a direct typecast to int behaves differently from a union typecast shows that the compiler handles this differently. Bernd Schmidt wrote: > > I used the following test program with the following version of GCC: > > gcc version 2.96 19990912 (experimental) i486-pc-linux-gnu > > > > It showed that all union constructs were alias safe when compared to the > > plain typecast version > > You can't show that something is safe this way. If your programs work, then > the compiler did not choose to take advantage of its aliasing information > for this input. That doesn't mean it won't do so for any other program. It > takes only one counterexample to show that the "cast to union" method is not > safe either, and such an example exists. > > Bernd From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Marcel Cox" To: Bernd Schmidt Cc: gcc@gcc.gnu.org, jbuck@synopsys.COM, rms@gnu.org Subject: Re: type based aliasing again Date: Thu, 30 Sep 1999 18:02:00 -0000 Message-ID: <37DE5830.EC1FAE36@cie.etat.lu> References: X-SW-Source: 1999-09n/msg00534.html Message-ID: <19990930180200.37AFSN2hX8167g5QUaSVnRA7Wi0iWdachXx6PGeAtew@z> I know this does not proof it is safe. The fact however that a direct typecast to int behaves differently from a union typecast shows that the compiler handles this differently. Bernd Schmidt wrote: > > I used the following test program with the following version of GCC: > > gcc version 2.96 19990912 (experimental) i486-pc-linux-gnu > > > > It showed that all union constructs were alias safe when compared to the > > plain typecast version > > You can't show that something is safe this way. If your programs work, then > the compiler did not choose to take advantage of its aliasing information > for this input. That doesn't mean it won't do so for any other program. It > takes only one counterexample to show that the "cast to union" method is not > safe either, and such an example exists. > > Bernd