public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/112346] New: Wrong code produced with -O2
@ 2023-11-02 8:56 fchelnokov at gmail dot com
2023-11-02 9:05 ` [Bug tree-optimization/112346] [13 Regression] " pinskia at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: fchelnokov at gmail dot com @ 2023-11-02 8:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112346
Bug ID: 112346
Summary: Wrong code produced with -O2
Product: gcc
Version: 13.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: fchelnokov at gmail dot com
Target Milestone: ---
This program
#include <ctype.h>
char *SkipAName(char *s) {
if (('A' <= *s && *s <= 'Z') || ('a' <= *s && *s <= 'z') ) {
while (isalnum(*s)) {
s++;
}
}
return s;
}
int TestName(char *name) {
while (*name)
name++;
return 0;
}
int StrICmp(char *s1, char *s2) {
while (*s1 && *s1 == *s2) {
s1++;
s2++;
}
return *s1 - *s2;
}
int DoTable(char *s) {
char *name, c;
name = s;
s = SkipAName(s);
c = *s;
*s = 0;
TestName(name);
*s = c;
if (*s == '(')
return 3;
if (*s != ',')
return 2;
*s = 0;
return StrICmp(name, "sparse");
}
int main() {
char buf[] = "sparse,C(1)";
return DoTable(buf);
}
shall return 0, but in GCC 13 with -O2 it returns 44. Online demo:
https://gcc.godbolt.org/z/c6W33T1zK
Related discussion: https://stackoverflow.com/q/77407156/7325599
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/112346] [13 Regression] Wrong code produced with -O2
2023-11-02 8:56 [Bug c/112346] New: Wrong code produced with -O2 fchelnokov at gmail dot com
@ 2023-11-02 9:05 ` pinskia at gcc dot gnu.org
2023-11-02 9:17 ` shaohua.li at inf dot ethz.ch
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-02 9:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112346
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |DUPLICATE
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 111519 which will be included in the GCC 13.3.0 release.
*** This bug has been marked as a duplicate of bug 111519 ***
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/112346] [13 Regression] Wrong code produced with -O2
2023-11-02 8:56 [Bug c/112346] New: Wrong code produced with -O2 fchelnokov at gmail dot com
2023-11-02 9:05 ` [Bug tree-optimization/112346] [13 Regression] " pinskia at gcc dot gnu.org
@ 2023-11-02 9:17 ` shaohua.li at inf dot ethz.ch
2023-11-02 9:20 ` sjames at gcc dot gnu.org
2023-11-02 9:23 ` fchelnokov at gmail dot com
3 siblings, 0 replies; 5+ messages in thread
From: shaohua.li at inf dot ethz.ch @ 2023-11-02 9:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112346
Shaohua Li <shaohua.li at inf dot ethz.ch> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |shaohua.li at inf dot ethz.ch
--- Comment #2 from Shaohua Li <shaohua.li at inf dot ethz.ch> ---
(In reply to Fedor Chelnokov from comment #0)
> This program
>
> #include <ctype.h>
>
> char *SkipAName(char *s) {
> if (('A' <= *s && *s <= 'Z') || ('a' <= *s && *s <= 'z') ) {
> while (isalnum(*s)) {
> s++;
> }
> }
> return s;
> }
>
> int TestName(char *name) {
> while (*name)
> name++;
> return 0;
> }
>
> int StrICmp(char *s1, char *s2) {
> while (*s1 && *s1 == *s2) {
> s1++;
> s2++;
> }
> return *s1 - *s2;
> }
>
> int DoTable(char *s) {
> char *name, c;
> name = s;
> s = SkipAName(s);
> c = *s;
> *s = 0;
> TestName(name);
> *s = c;
> if (*s == '(')
> return 3;
> if (*s != ',')
> return 2;
> *s = 0;
> return StrICmp(name, "sparse");
> }
>
> int main() {
> char buf[] = "sparse,C(1)";
> return DoTable(buf);
> }
>
> shall return 0, but in GCC 13 with -O2 it returns 44. Online demo:
> https://gcc.godbolt.org/z/c6W33T1zK
>
> Related discussion: https://stackoverflow.com/q/77407156/7325599
Hi, it seems that this test case is reduced from a real project. Could you tell
me which project it is from?
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/112346] [13 Regression] Wrong code produced with -O2
2023-11-02 8:56 [Bug c/112346] New: Wrong code produced with -O2 fchelnokov at gmail dot com
2023-11-02 9:05 ` [Bug tree-optimization/112346] [13 Regression] " pinskia at gcc dot gnu.org
2023-11-02 9:17 ` shaohua.li at inf dot ethz.ch
@ 2023-11-02 9:20 ` sjames at gcc dot gnu.org
2023-11-02 9:23 ` fchelnokov at gmail dot com
3 siblings, 0 replies; 5+ messages in thread
From: sjames at gcc dot gnu.org @ 2023-11-02 9:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112346
Sam James <sjames at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |sjames at gcc dot gnu.org
--- Comment #3 from Sam James <sjames at gcc dot gnu.org> ---
Yes, if allowed/able, please do always mention where something got derived
from. It can be useful data.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/112346] [13 Regression] Wrong code produced with -O2
2023-11-02 8:56 [Bug c/112346] New: Wrong code produced with -O2 fchelnokov at gmail dot com
` (2 preceding siblings ...)
2023-11-02 9:20 ` sjames at gcc dot gnu.org
@ 2023-11-02 9:23 ` fchelnokov at gmail dot com
3 siblings, 0 replies; 5+ messages in thread
From: fchelnokov at gmail dot com @ 2023-11-02 9:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112346
--- Comment #4 from Fedor Chelnokov <fchelnokov at gmail dot com> ---
According to referenced stackoverflow discussion, the code is reduced from
https://github.com/vermaseren/form see
https://github.com/vermaseren/form/issues/461
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-11-02 9:23 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-02 8:56 [Bug c/112346] New: Wrong code produced with -O2 fchelnokov at gmail dot com
2023-11-02 9:05 ` [Bug tree-optimization/112346] [13 Regression] " pinskia at gcc dot gnu.org
2023-11-02 9:17 ` shaohua.li at inf dot ethz.ch
2023-11-02 9:20 ` sjames at gcc dot gnu.org
2023-11-02 9:23 ` fchelnokov at gmail dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).