https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120979
Bug ID: 120979 Summary: Missed strdup to malloc + memcpy for known strings Product: gcc Version: 16.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: kaelfandrew at gmail dot com Target Milestone: --- Created attachment 61810 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=61810&action=edit C code Flags with -O3. strdup() shouldn't be called for const strings like "Hello". Real code that could be optimized include https://github.com/gcc-mirror/gcc/blob/57d30924e2b3887a1aedc6102daa67bc3272ace7/gcc/config/aarch64/aarch64.cc#L19381 ``` static char * aarch64_offload_options (void) { if (TARGET_ILP32) return xstrdup ("-foffload-abi=ilp32 -foffload-abi-host-opts=-mabi=ilp32"); else return xstrdup ("-foffload-abi=lp64 -foffload-abi-host-opts=-mabi=lp64"); } ```