Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!eos!agate!ucbvax!ucsd!orion.cf.uci.edu!uci-ics!crimee.ics.uci.edu!schmidt From: schmidt@crimee.ics.uci.edu (Doug Schmidt) Newsgroups: gnu.g++.bug Subject: Re: BUG in GCC & G++ 1.32 using -O & inline & narrowing implicit casts Message-ID: <6591@paris.ics.uci.edu> Date: 3 Feb 89 04:05:19 GMT References: <8901312032.AA24614@riunite.aca.mcc.com> <8902010855.AA06237@marvin.moncam.uucp> Sender: news@paris.ics.uci.edu Reply-To: Doug Schmidt Distribution: gnu Organization: University of California at Irvine: ICS Dept. Lines: 41 In article <8902010855.AA06237@marvin.moncam.uucp> mcvax!moncam!paul@UUNET.UU.NET (Paul Hudson) writes: ++ ++As before, suggestions of futher warnings welcome. ++Paul Hudson ++ Here's a useful warning we could use in gcc and g++, given that it is now possible to declare ``const'' functions (read gcc.texinfo for gcc 1.33 for details). Imagine the following perverse program: ---------------------------------------- int external = 10; int bar () { external++; } const int foo (int *i) { bar(); return (external = *i = 10); } void main () { external = foo(&external) + external; } ---------------------------------------- Function foo violates just about all the restrictions on const functions, since it references global variables, changes its parameters, and calls a non-const function. However, gcc doesn't complain about this, yet. It would be nice to have a -W option that detected these transgressions. Doug -- schmidt@ics.uci.edu (ARPA) | Per me si va nella citta' dolente. office: (714) 856-4043 | Per me si va nell'eterno dolore. | Per me si va tra la perduta gente. | Lasciate ogni speranza o voi ch'entrate.