Article View: comp.unix.programmer
Article #3673Re: gcc -O2 bug
From: Christopher R Volpe
Date: Fri, 09 Aug 1996 00:00
Date: Fri, 09 Aug 1996 00:00
40 lines
2293 bytes
2293 bytes
Bryan Ischo wrote:
>
> In article <4udd3i$90k@solutions.solon.com> seebs@solutions.solon.com
> (Peter Seebach) writes:
> > Some versions might be, but it's an unlikely assumption.
>
> OK, I'm sure I'll be corrected if I am wrong, but ...
>
> C arguments are passed in by value, not by reference. So, if I write a
> function which takes an int as an argument, then the function will NOT be able
> to modify the "original" value. For example:
You're missing the point here. Let us assume for the moment that the
compiler proper is unaware of any special semantics associated with the
printf function. For all the compiler knows, there may be a a file
called printf.c that contains the following:
/* File printf.c */
extern int *flag_pt;
extern int getpid(); /* keep this relevant to comp.unix.programmer :) */
int printf(char *s, int a, int b, int c)
{
*flag_pt = a + b;
return c;
}
See why the compiler can't presume that flag doesn't get modified?
comp.std.c answer: The compiler is allowed to know the semantics of
printf, and should know that the printf function will not modify
flag_pt, despite the fact that other user-defined functions could.
--
Chris Volpe Phone: (518) 387-7766
GE Corporate R&D Fax: (518) 387-6560
PO Box 8 Email: volpecr@crd.ge.com
Schenectady, NY 12301 Web: http://www.crd.ge.com/~volpecr
Technical Details
Message-ID:
<320B6599.2C8E@ash.crd.ge.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<4ubnat$75u@freeside.fc.net> <danpop.839504721@news.cern.ch>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,7d30cae02ba9b089 X-Google-Attributes: gid11318c,public X-Google-Thread: 10c696,7d30cae02ba9b089 X-Google-Attributes: gid10c696,public X-Google-Thread: fc89c,7d30cae02ba9b089 X-Google-Attributes: gidfc89c,public X-Google-Thread: 1014db,7d30cae02ba9b089 X-Google-Attributes: gid1014db,public From: Christopher R Volpe <volpe@ash.crd.ge.com> Subject: Re: gcc -O2 bug Date: 1996/08/09 Message-ID: <320B6599.2C8E@ash.crd.ge.com> X-Deja-AN: 173175684 references: <4ubnat$75u@freeside.fc.net> <danpop.839504721@news.cern.ch> to: Bryan Ischo <bji@connectinc.com> content-type: text/plain; charset=us-ascii organization: GE Corporate Research & Development, Schenectady, NY mime-version: 1.0 newsgroups: comp.unix.programmer,gnu.gcc.help,comp.os.linux.development.apps,comp.lang.c x-mailer: Mozilla 2.0 (X11; I; SunOS 5.4 sun4m)