Date: Wed, 29 Jan 2003 19:38:54 +0200 From: "Eli Zaretskii" Sender: halo1 AT zahav DOT net DOT il To: djgpp AT delorie DOT com Message-Id: <7263-Wed29Jan2003193854+0200-eliz@is.elta.co.il> X-Mailer: emacs 21.3.50 (via feedmail 8 I) and Blat ver 1.8.9 In-reply-to: <3E37FAD5.4113C82A@yahoo.com> (message from CBFalconer on Wed, 29 Jan 2003 16:42:54 GMT) Subject: Re: Power at compilation time References: <3E37420D DOT 922C5B16 AT yahoo DOT com> <3E37FAD5 DOT 4113C82A AT yahoo DOT com> Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk > From: CBFalconer > Newsgroups: comp.lang.c,comp.os.msdos.djgpp > Date: Wed, 29 Jan 2003 16:42:54 GMT > > > > > What version of gcc are you using, and what flags? With gcc 3.2 > > > on a x86 GNU/Linux system and -O2 optimization, this code > > > > > > #include > > > size_t foo (const char *s) { return strlen (s); } > > > > > > generates `repnz scasb' as the loop to scan for the '\0' > > > character. > > Not here. Under DJGPP, gcc 3.2.1 with: > > gcc -W -Wall -ansi -pedantic -gstabs+ -O2 -Wa,-alhn=strlgh.s > strlgh.c > > gives the following listing with the stabs lines deleted (long > lines, thus pasted as quote): > > -minline-all-stringops doesn't bring in any scasb sequences > either. I'd say GCC 3.2.1 is broken in this respect, and suggest to report that to the GCC bug-reporting list. The GCC docs clearly says that string functions such as strlen are inlined by default. > (All this may have more to do with the library than gcc) No, compiler optimizations such as this one have nothing to do with the library. The only part of the library that the compiler sees is the header files included by the program it compiles.