https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83278
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Known to fail| |8.3.0, 9.2.0 Known to work| |10.0 Status|UNCONFIRMED |RESOLVED Resolution|--- |FIXED Last reconfirmed| |2020-5-1 --- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> --- Since r276469 GCC 10 inlines all three calls and so it issues the expected diagnostics. GCC 9 declines to inline the call to h() in call_h(). pr83278.c: In function ‘call_f’: pr83278.c:7:26: warning: ‘%s’ directive writing 5 bytes into a region of size 3 [-Wformat-overflow=] 7 | __builtin_sprintf (a, "%s", s); // warning (good) | ^~ ...... 14 | f ("12345"); | ~~~~~~~ pr83278.c:7:3: note: ‘__builtin_sprintf’ output 6 bytes into a destination of size 3 7 | __builtin_sprintf (a, "%s", s); // warning (good) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ pr83278.c: In function ‘call_g’: pr83278.c:22:60: warning: ‘%s’ directive writing 6 bytes into a region of size 3 [-Wformat-overflow=] 22 | __builtin_object_size (a, 1), "%s", s); | ^~ ...... 27 | g ("123456"); | ~~~~~~~~ pr83278.c:21:3: note: ‘__builtin___sprintf_chk’ output 7 bytes into a destination of size 3 21 | __builtin___sprintf_chk (a, 1, // duplicate warning | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 22 | __builtin_object_size (a, 1), "%s", s); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ pr83278.c: In function ‘call_h’: pr83278.c:35:59: warning: ‘%s’ directive writing 7 bytes into a region of size 3 [-Wformat-overflow=] 35 | __builtin_object_size (a, 1), "%s", s); | ^~ ...... 42 | h ("1234567"); | ~~~~~~~~~ pr83278.c:34:3: note: ‘__builtin___sprintf_chk’ output 8 bytes into a destination of size 3 34 | __builtin___sprintf_chk (a, 1, // missing warning (bug) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 35 | __builtin_object_size (a, 1), "%s", s); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~