[Bug tree-optimization/120979] Missed strdup to malloc + memcpy for known strings

2025-07-07 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120979 --- Comment #4 from Richard Biener --- I guess we miss a memdup, using strndup instead of strdup might be a small improvement. I don't think inlining it is a good thing to do, this should be addressed at the library level.

[Bug tree-optimization/120979] Missed strdup to malloc + memcpy for known strings

2025-07-06 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120979 --- Comment #3 from Andrew Pinski --- Also as I mentioned xstrdup is not linked at all to the normal strdup (it is a wrapper around strdup which will error out [and exit] if strdup returns NULL).

[Bug tree-optimization/120979] Missed strdup to malloc + memcpy for known strings

2025-07-06 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120979 --- Comment #2 from Andrew Pinski --- (In reply to Andrew Pinski from comment #1) > Note xstrdup is not the same as strdup ... > > ``` > char *a() > { > return __builtin_strdump (""); Sorry typo, __builtin_strdup. > } > ``` > > Would

[Bug tree-optimization/120979] Missed strdup to malloc + memcpy for known strings

2025-07-06 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120979 --- Comment #1 from Andrew Pinski --- Note xstrdup is not the same as strdup ... ``` char *a() { return __builtin_strdump (""); } ``` Would need to be changed into: ``` char *a() { const char tt[] = ""; char *t = __builtin_mallo

[Bug tree-optimization/120979] Missed strdup to malloc + memcpy for known strings

2025-07-06 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120979 Andrew Pinski changed: What|Removed |Added Severity|normal |enhancement Keywords|