Article View: comp.unix.programmer
Article #3677Re: gcc -O2 bug
From: Mike Rubenstein
Date: Sat, 10 Aug 1996 00:00
Date: Sat, 10 Aug 1996 00:00
28 lines
2028 bytes
2028 bytes
crow@coos.dartmouth.edu (Preston F. Crow) wrote: > Christopher R Volpe <volpe@ash.crd.ge.com> writes: > > >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. > > No, the compiler can't assume anything about printf(), as the user > could have stupidly defined his own function of the same name, > overriding the expected behaviour of the version in libc. > > In some of my Mach programming, I've done just that. [Well, with > different functions, where the normal version had problems, but > still...] > > Never expect a compiler to be smart, but always be prepared for it to > outsmart you. NO. The compiler may assume that you have not replaced printf() with another function. Replacing a standard library function results in undefined behavior -- the compiler may do anything. See ISO 7.1.3. Just because some compiler allowed you to do this, does not mean it is legal. Michael M Rubenstein
Technical Details
Message-ID:
<320cc447.61487233@nntp.ix.netcom.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<4ubnat$75u@freeside.fc.net> <danpop.839504721@news.cern.ch> <vkohklaizj.fsf@atari.connectinc.com> <4udd3i$90k@solutions.solon.com> <vkn3059yhu.fsf@atari.connectinc.com> <320B6599.2C8E@ash.crd.ge.com> <4uh4vh$aj2@dartvax.dartmouth.edu>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: miker3@ix.netcom.com (Mike Rubenstein) Subject: Re: gcc -O2 bug Date: 1996/08/10 Message-ID: <320cc447.61487233@nntp.ix.netcom.com> X-Deja-AN: 173377027 references: <4ubnat$75u@freeside.fc.net> <danpop.839504721@news.cern.ch> <vkohklaizj.fsf@atari.connectinc.com> <4udd3i$90k@solutions.solon.com> <vkn3059yhu.fsf@atari.connectinc.com> <320B6599.2C8E@ash.crd.ge.com> <4uh4vh$aj2@dartvax.dartmouth.edu> organization: Netcom x-netcom-date: Sat Aug 10 12:24:54 PM CDT 1996 newsgroups: comp.unix.programmer,gnu.gcc.help,comp.os.linux.development.apps,comp.lang.c