Date: Mon, 12 Aug 2002 10:47:21 +0100 From: David Malone <dwmalone@maths.tcd.ie> To: Dan Lukes <dan@obluda.cz> Cc: freebsd-bugs@FreeBSD.org, bde@FreeBSD.org Subject: Re: bin/40209: __dtoa broken with -O2 or -O3 optimisation Message-ID: <200208121047.aa31878@salmon.maths.tcd.ie> In-Reply-To: Your message of "Mon, 12 Aug 2002 10:33:17 %2B0200." <3D5772CD.7000908@obluda.cz>
next in thread | previous in thread | raw e-mail | index | archive | help
> > I guess that changing x by accessing word0 or word1 is a violation > > of the aliasing rules. The deinitions might work: > I never listen about "aliasing rules". Where I can found something to > read about it ? It is a part of the C standard which was little known until gcc started using it for optimisation ;-) In section 6.5 (paragraph 7) of the C99 standard it say: An object shall have its stored value accessed only by an lvalue expression that has one of the following types: - a type compatible with the effective type of the object, - a qualified version of a type compatible with the effective type of the object, - a type that is the signed or unsigned type corresponding to the effective type of the object, - a type that is the signed or unsigned type corresponding to a qualified version of the effective type of the object, - an aggregate or union type that includes one of the aforementioned types among its members (including, recursively, a member of a subaggregate or contained union), or - a character type. This means that if you access a ULong then the compiler can assume that no doubles change their value 'cos their types are not compatible. By makeing them a member of a union, the compiler then knows that they may alias one another and so has to be more conservative. (I got my copy of the C standard from the ANSI web site in PDF for about 20 dollars, but I think there are final drafts available for free - it can be quite useful to have around.) If Bruce thinks the new definitions for word0 and word1 look OK then I can commit them. BTW - how similar was the original and fixed code? David. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200208121047.aa31878>
