[Bug c/58240] GCC optimize strncmp when N=1 incorrectly

2013-08-26 Thread shiyan2016 at 126 dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58240 --- Comment #13 from shiyan --- Hi all, Thank you for all your explanation. This seems more like a philosophical discussion :) I do can understand what GCC is doing (as I mentioned, it may be optimized to *s1-*s2). And I know that this is som

[Bug c/58240] GCC optimize strncmp when N=1 incorrectly

2013-08-26 Thread jakub at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58240 Jakub Jelinek changed: What|Removed |Added CC||jakub at gcc dot gnu.org --- Comment #12

[Bug c/58240] GCC optimize strncmp when N=1 incorrectly

2013-08-26 Thread glisse at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58240 --- Comment #11 from Marc Glisse --- (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 itbut whatever, it is a > bug. in your c

[Bug c/58240] GCC optimize strncmp when N=1 incorrectly

2013-08-25 Thread pinskia at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58240 --- Comment #10 from Andrew Pinski --- (In reply to shiyan from comment #7) > (In reply to Marc Glisse from comment #4) > > -fno-builtin (or some better such option)? > > strncmp is a standard function, your code redefining it has undefined > > be

[Bug c/58240] GCC optimize strncmp when N=1 incorrectly

2013-08-25 Thread shiyan2016 at 126 dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58240 --- Comment #9 from shiyan --- (In reply to Paolo Carlini from comment #5) > Closing then. Hi Carlini, I still think it is a bug. I know the test case is not practical. In fact, I will not use such code in real case. But from compiler's side, th

[Bug c/58240] GCC optimize strncmp when N=1 incorrectly

2013-08-25 Thread shiyan2016 at 126 dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58240 --- Comment #8 from shiyan --- (In reply to Jakub Jelinek from comment #6) > The testcase is clearly bogus. You are not using the result of either of > the strncmp calls, strncmp is a pure function, so it is fine not to call it > at all. Hi Jeli

[Bug c/58240] GCC optimize strncmp when N=1 incorrectly

2013-08-25 Thread shiyan2016 at 126 dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58240 --- Comment #7 from shiyan --- (In reply to Marc Glisse from comment #4) > -fno-builtin (or some better such option)? > strncmp is a standard function, your code redefining it has undefined > behavior. gcc optimizes based on the standard behavior

[Bug c/58240] GCC optimize strncmp when N=1 incorrectly

2013-08-25 Thread jakub at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58240 --- Comment #6 from Jakub Jelinek --- The testcase is clearly bogus. You are not using the result of either of the strncmp calls, strncmp is a pure function, so it is fine not to call it at all.

[Bug c/58240] GCC optimize strncmp when N=1 incorrectly

2013-08-25 Thread paolo.carlini at oracle dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58240 Paolo Carlini changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution|---

[Bug c/58240] GCC optimize strncmp when N=1 incorrectly

2013-08-25 Thread glisse at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58240 --- Comment #4 from Marc Glisse --- -fno-builtin (or some better such option)? strncmp is a standard function, your code redefining it has undefined behavior. gcc optimizes based on the standard behavior of the function.

[Bug c/58240] GCC optimize strncmp when N=1 incorrectly

2013-08-25 Thread paolo.carlini at oracle dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58240 Paolo Carlini changed: What|Removed |Added CC|shiyan2016 at 126 dot com | --- Comment #3 from Paolo Carlini

[Bug c/58240] GCC optimize strncmp when N=1 incorrectly

2013-08-25 Thread shiyan2016 at 126 dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58240 --- Comment #2 from shiyan --- (In reply to Paolo Carlini from comment #1) > I can't reproduce this. Hi, What is your GCC version? I am using gcc4.7.2. My OS information are as below: $lsb_release -a No LSB modules are available. Distributor ID:

[Bug c/58240] GCC optimize strncmp when N=1 incorrectly

2013-08-25 Thread paolo.carlini at oracle dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58240 Paolo Carlini changed: What|Removed |Added CC|shiyan2016 at 126 dot com | --- Comment #1 from Paolo Carlini