From owner-freebsd-current Mon Nov 15 10:35:25 1999 Delivered-To: freebsd-current@freebsd.org Received: from khavrinen.lcs.mit.edu (khavrinen.lcs.mit.edu [18.24.4.193]) by hub.freebsd.org (Postfix) with ESMTP id 89A5914A01 for ; Mon, 15 Nov 1999 10:35:22 -0800 (PST) (envelope-from wollman@khavrinen.lcs.mit.edu) Received: (from wollman@localhost) by khavrinen.lcs.mit.edu (8.9.3/8.9.3) id NAA07676; Mon, 15 Nov 1999 13:35:15 -0500 (EST) (envelope-from wollman) Date: Mon, 15 Nov 1999 13:35:15 -0500 (EST) From: Garrett Wollman Message-Id: <199911151835.NAA07676@khavrinen.lcs.mit.edu> To: Pierre Beyssac Cc: Sheldon Hearn , freebsd-current@FreeBSD.ORG Subject: Re: egcs -O breaks ping.c:in_cksum() In-Reply-To: <19991115180145.A31542@enst.fr> References: <19991115174831.B30139@enst.fr> <92805.942684743@axl.noc.iafrica.com> <19991115180145.A31542@enst.fr> Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG < said: > Maybe I can at least commit the addition of "volatile" to the source > code. That will work around that particular bug until egcs is > fixed... It's not a compiler bug, it's a source code bug. The C Language specifies that pointers to distinct types can be assumed, under certain conditions, never to alias one another. (This might actually be a C99 feature as opposed to C89.) Recent values of GCC make use of this obscure language feature to improve optimization. Essentially, the optimizer can assume that stores through a pointer of type `foo *' will never modify any local variable which is not of type `foo' (and thus those values can remain cached in registers). If, rather than casting pointers, the code used a union (containing one u_int16_t and one array[2] of u_int8_t), the compiler would have enough information to know about the aliases. -GAWollman -- Garrett A. Wollman | O Siem / We are all family / O Siem / We're all the same wollman@lcs.mit.edu | O Siem / The fires of freedom Opinions not those of| Dance in the burning flame MIT, LCS, CRS, or NSA| - Susan Aglukark and Chad Irschick To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message