Article View: comp.sys.ibm.pc.programmer
Article #614Re: No Aliasing Compile Option
From: Mark ROBERTS
Date: Tue, 05 Jun 1990 17:02
Date: Tue, 05 Jun 1990 17:02
44 lines
1446 bytes
1446 bytes
In article <12215@bunker.UUCP> shap@clunker.UUCP (Joseph D. Shapiro) writes:
>In file a.c
>
> static int foo;
>
> main()
> { bar(foo); }
>
> baz()
> { foo++; }
>
>in file b.c
>
> foo(int x)
> { ... establish a value for x here ...
> baz();
> ... reference x here ...
> }
>
>is this not aliasing as well?
>will not -Oa cause trouble in b.c?
Well, sort of. I think you have a couple of problems with your example -
the function foo should be named bar and since ints are passed by value
there can be no aliasing. But, try this:
static int foo;
main()
{ bar(&foo); }
baz()
{ foo++; }
int bar(int *x)
{
*x=3;
baz();
return *x;
}
Now you've got aliasing and -Oa will fail, even in same file. But is it
the same example? Do people really write code like this? I would certainly
not encourage this, but no doubt its done. In which case, you can't use
-Oa; however, -Ow would work.
Technical Details
Message-ID:
<55054@microsoft.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uunet!microsoft!markroReferences:
<1990May23.234917.21858@uunet!unhd> <250@demott.COM> <12215@bunker.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uunet!microsoft!markro From: markro@microsoft.UUCP (Mark ROBERTS) Newsgroups: comp.sys.ibm.pc.programmer Subject: Re: No Aliasing Compile Option Keywords: Microsoft 6.0 C update woes Message-ID: <55054@microsoft.UUCP> Date: 5 Jun 90 17:02:22 GMT References: <1990May23.234917.21858@uunet!unhd> <250@demott.COM> <12215@bunker.UUCP> Reply-To: markro@microsoft.UUCP (Mark ROBERTS) Organization: Microsoft Corp., Redmond WA Lines: 44