http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58240

--- Comment #11 from Marc Glisse <glisse at gcc dot gnu.org> ---
(In reply to shiyan from comment #7)
> Thank you for the suggestion. Yes, I know -fno-builtin can work around it. I
> can think of many possible ways to work around it....but whatever, it is a
> bug.

in your code.

> As I known, redefining a function (override?) is not supported in
> standard C, but first most of compiler supports this including GCC itself

if you pass suitable options to tell the compiler you are doing that. Gcc
supports compiling the linux kernel, but that also requires some special
options, like anything non-standard.

> and second it should behaviour consistently as a compiler. It is really
> crazy that it will not work when N=1 only.

No, that's perfectly normal. Note that N==0 is optimized as well. Gcc optimizes
only when there is something to optimize (N small enough).

> Also, all other mainstream compiler can work well. And it cannot work with
> -O0 also, which means it is not an optimization of code generation.

It is, because gcc does early optimizations during parsing (which it arguably
shouldn't, that's a known design issue) regardless of the optimization flags.

> Maybe it
> just replace strncmp(s1, s2, 1) with (*s1-*s2),

Yes.

Reply via email to