Date: Mon, 11 Nov 2002 13:02:45 -0500 (EST) From: Thomas David Rivers <rivers@dignus.com> To: brandt@fokus.gmd.de, rivers@dignus.com Cc: FreeBSD-current@FreeBSD.ORG, gallatin@cs.duke.edu Subject: Re: gcc 3.2.1 optimization bug ? Message-ID: <200211111802.gABI2jX55939@lakes.dignus.com> In-Reply-To: <20021111172959.W32091-100000@beagle.fokus.gmd.de>
next in thread | previous in thread | raw e-mail | index | archive | help
Harti Brandt <brandt@fokus.gmd.de> wrote:
>
>
> Hmm, I though the following would work:
>
> void
> foo(unsigned short *s)
> {
> unsigned short temp;
>
> temp = s[0];
> s[0] = s[1];
> s[1] = temp;
> }
>
> main()
> {
> int i = 0x12345678;
>
> foo(&i);
> printf("%08x\n", i);
> }
>
> because how would the compiler in main() know, that you do something wrong
> in foo(). But... if you compile this with -O5, it does not work! This is
> because the compiler inlines foo() into main and the program prints junk like
> 0x12342804.
Nope - that doesn't work either. The call to foo() is not compatible
with the prototype (in fact, the Systems/C compiler issues a warning
on this:
Warning #2034: passing argument 1 from incompatible pointer type
I believe gcc would as well.
- Dave Rivers -
--
rivers@dignus.com Work: (919) 676-0847
Get your mainframe programming tools at http://www.dignus.com
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?200211111802.gABI2jX55939>
