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

            Bug ID: 110318
           Summary: Unused string literal is retained in assembler file
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: roland.illig at gmx dot de
  Target Milestone: ---

~~~c
typedef typeof(sizeof 0) size_t;

int memcmp(const void *, const void *, size_t);

int demo(const char *);

int demo(const char *p) {
        const char *start = p;
        while (*p == 'C')
                p++;
        if (p - start == 2 && memcmp(start, "if", 2) == 0)
                return 2;
        if (p - start == 6 && memcmp(start, "ifndef", 6) == 0)
                return 6;
        return 0;
}
~~~

$ uname -a
NetBSD nbcurr.roland-illig.de 10.99.3 NetBSD 10.99.3 (GENERIC) #0: Fri Apr 21
02:17:32 UTC 2023
$ gcc-12.2.0 -O2 -S code.c
$ grep string code.s
        .string "ifndef"


The string "ifndef" is retained, even though it is not used in the code,
because the comparison is inlined. Curiously, the string "if" is removed.

Both strings should be removed, as they are unnecessary.

Reply via email to