Mail Archives: djgpp/2003/01/29/12:41:40
> From: CBFalconer <cbfalconer AT yahoo DOT com>
> 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 <string.h>
> > > 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.
- Raw text -