[Bug c/108715] New: Infinite loop in the generated assembly with -Os when strlen is defined in the code

daniel at eyoman dot com gcc-bugzilla@gcc.gnu.org
Wed Feb 8 10:29:33 GMT 2023


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108715

            Bug ID: 108715
           Summary: Infinite loop in the generated assembly with -Os when
                    strlen is defined in the code
           Product: gcc
           Version: 12.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: daniel at eyoman dot com
  Target Milestone: ---

Created attachment 54426
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54426&action=edit
C file

Hi,

The attached source file is compiled on GCC 12.2.1 with the following command:
gcc -save-temps -Wall -Wextra -Os strlen_bug.c -o strlen_bug

The assembly file, obtained with objdump -d strlen_bug, shows that:
- the for loop dealing with the length calculation has been removed by strlen
- the strlen label jumps to itself
- the program never ends

If the strlen function is removed from the code, the problem doesn't occur.

I wanted to attach the assembly and preprocessed files but I could attach only
one.


More information about the Gcc-bugs mailing list