From owner-freebsd-current Mon Nov 15 11:28: 5 1999 Delivered-To: freebsd-current@freebsd.org Received: from apollo.backplane.com (apollo.backplane.com [216.240.41.2]) by hub.freebsd.org (Postfix) with ESMTP id 25CBA150A7 for ; Mon, 15 Nov 1999 11:28:02 -0800 (PST) (envelope-from dillon@apollo.backplane.com) Received: (from dillon@localhost) by apollo.backplane.com (8.9.3/8.9.1) id LAA44755; Mon, 15 Nov 1999 11:27:57 -0800 (PST) (envelope-from dillon) Date: Mon, 15 Nov 1999 11:27:57 -0800 (PST) From: Matthew Dillon Message-Id: <199911151927.LAA44755@apollo.backplane.com> To: Garrett Wollman Cc: Pierre Beyssac , Sheldon Hearn , freebsd-current@FreeBSD.ORG Subject: Re: egcs -O breaks ping.c:in_cksum() References: <19991115174831.B30139@enst.fr> <92805.942684743@axl.noc.iafrica.com> <19991115180145.A31542@enst.fr> <199911151835.NAA07676@khavrinen.lcs.mit.edu> Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG :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 :... :Recent values of GCC make use of this obscure language feature to :improve optimization. Essentially, the optimizer can assume that :... :-GAWollman : :-- :Garrett A. Wollman | O Siem / We are all family / O Siem / We're all the same Someone try the patch below and tell me if it fixes the problem. If it does then I'll commit it. If someone else wants to commit a 'better' fix, be my guest! (but inform the list that you've done so). Otherwise this is the one that will go in. -Matt Index: ping.c =================================================================== RCS file: /home/ncvs/src/sbin/ping/ping.c,v retrieving revision 1.45 diff -u -r1.45 ping.c --- ping.c 1999/08/28 00:13:59 1.45 +++ ping.c 1999/11/15 19:26:23 @@ -920,6 +920,9 @@ /* * in_cksum -- * Checksum routine for Internet Protocol family headers (C Version) + * + * note: volatilization of 'answer' is a bad hack to work around an + * aliasing problem. */ u_short in_cksum(addr, len) @@ -929,7 +932,7 @@ register int nleft = len; register u_short *w = addr; register int sum = 0; - u_short answer = 0; + volatile u_short answer = 0; /* * Our algorithm is simple, using a 32 bit accumulator (sum), we add To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message