https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104746
Martin Liška <marxin at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |NEW Resolution|INVALID |--- --- Comment #3 from Martin Liška <marxin at gcc dot gnu.org> --- > That said, the warning persists even with a buffer of sufficient size, but > then disappears if the empty definition of systemd_escape2() is removed. > Since the function fails to return a result the test case is invalid, I'm > guessing because it was reduced too far. Can you provide a valid test case? > Sure, there's a valid test-case that is completely fine and we emit a warning: $ cat problem.c #include <stdio.h> #include <string.h> #include <stdlib.h> int main(int argc, char *argv[]) { const char *pipefs_path = argv[1]; const char *dirname = argv[1]; const char *suffix = ".mount"; int len = strlen(pipefs_path); char *result = malloc(len + strlen(suffix) + 1); sprintf(result, "%s", suffix); char *path = malloc(strlen(dirname) + strlen(result) + 2); sprintf(path, "%s/%s", dirname, result); return 0; }