public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/106349] New: strlen reimplementation produces infinite loop with -Os
@ 2022-07-18 22:39 vincent.riviere at freesbee dot fr
2022-07-18 22:42 ` [Bug tree-optimization/106349] " pinskia at gcc dot gnu.org
2022-07-18 22:44 ` pinskia at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: vincent.riviere at freesbee dot fr @ 2022-07-18 22:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106349
Bug ID: 106349
Summary: strlen reimplementation produces infinite loop with
-Os
Product: gcc
Version: 12.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: vincent.riviere at freesbee dot fr
Target Milestone: ---
Target: m68k-elf
Compiling a function named strlen with strlen-like body generates an infinite
loop.
$ cat bug.c
#include <stddef.h>
size_t strlen(const char *str)
{
size_t n;
for (n = 0; *str++; n++);
return n;
}
$ m68k-elf-gcc -S bug.c -o - -Os
#NO_APP
.file "bug.c"
.text
.align 2
.globl strlen
.type strlen, @function
strlen:
jra strlen
.size strlen, .-strlen
.ident "GCC: (GNU) 12.1.0"
The only generated code is the infinite loop. That's a nonsense.
This issue doesn't occur with -O2.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/106349] strlen reimplementation produces infinite loop with -Os
2022-07-18 22:39 [Bug c/106349] New: strlen reimplementation produces infinite loop with -Os vincent.riviere at freesbee dot fr
@ 2022-07-18 22:42 ` pinskia at gcc dot gnu.org
2022-07-18 22:44 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-07-18 22:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106349
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|c |tree-optimization
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
There are a few duplicates of this one. Basically the same optimization is also
done for memcpy too.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/106349] strlen reimplementation produces infinite loop with -Os
2022-07-18 22:39 [Bug c/106349] New: strlen reimplementation produces infinite loop with -Os vincent.riviere at freesbee dot fr
2022-07-18 22:42 ` [Bug tree-optimization/106349] " pinskia at gcc dot gnu.org
@ 2022-07-18 22:44 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-07-18 22:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106349
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |DUPLICATE
Status|UNCONFIRMED |RESOLVED
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 102725.
*** This bug has been marked as a duplicate of bug 102725 ***
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-07-18 22:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-18 22:39 [Bug c/106349] New: strlen reimplementation produces infinite loop with -Os vincent.riviere at freesbee dot fr
2022-07-18 22:42 ` [Bug tree-optimization/106349] " pinskia at gcc dot gnu.org
2022-07-18 22:44 ` pinskia at gcc dot gnu.org
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).