Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 11 Nov 2002 23:15:59 +0900
From:      TOMITA Yoshinori <yoshint@flab.fujitsu.co.jp>
To:        Thomas David Rivers <rivers@dignus.com>
Cc:        FreeBSD-current@FreeBSD.ORG, yoshint@flab.fujitsu.co.jp
Subject:   Re: gcc 3.2.1 optimization bug ?
Message-ID:  <ywlfzu8i44g.fsf@cerberus.proc.flab.fujitsu.co.jp>
In-Reply-To: <200211111355.gABDt2g55397@lakes.dignus.com> (Thomas David Rivers's message of "Mon, 11 Nov 2002 08:55:02 -0500 (EST)")
References:  <ywlvg34jn21.fsf@cerberus.proc.flab.fujitsu.co.jp> <200211111355.gABDt2g55397@lakes.dignus.com>

next in thread | previous in thread | raw e-mail | index | archive | help
>> On Mon, 11 Nov 2002 08:55:02 -0500 (EST), Thomas David Rivers <rivers@dignus.com> said:

Th>  Several people have pointed out that using "volatile" will
Th>  help with your code.

Th>  But - even with the use of "volatile" - your code is invalid ANSI
Th>  C.
--snip--

Thanks for your detailed explanation. It cleared me more.


Th>  Your code appears to simply want to swap the two (assumed) words in
Th>  an integer.  That could be accomplished with shifts, etc...
Th>  This code makes all kinds of assumptions about the size of
Th>  `int' and `short' - but represents an alternative approach:

Th> 	unsigned int t;
Th> 	unsigned int x;

Th> 	t = (x & 0xffff) << 16;
Th> 	x >>= 16;
Th> 	x |= t;

Th>  Assuming `int' was 32-bits wide - this, or something similar,
Th>  might be a more portable approach.
 

Yes, I agree with your example code.

But unfortunately, that ugly code was contained in our inhouse library
written by someone.
It took me two days to debug and find out where difference comes from
between gcc-2.95.4 and gcc-3.2.1.


-- 
TOMITA Yoshinori


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?ywlfzu8i44g.fsf>