https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103835
--- Comment #4 from lavr at ncbi dot nlm.nih.gov --- Thank you for investigating this! Like I said, it's better NOT to emit any warnings if some machinery in the compiler is not perfect enough to recognize the danger correctly (as it used to be the case in previous versions and so they were silent in this respect). There is the second warning there, too, which seems not being addressed by the discussion. Not only the count (499) is not given correctly (but maybe it's because of the constant propagation that was mentioned), there's the second part (the note), which follows, and which looks extremely bad and unintelligent w.r.t. the output size calculation: test.c:8:21: warning: ‘a = ’ directive writing 4 bytes into a region of size between 0 and 499 [-Wformat-overflow=] 8 | sprintf(buf, "%sa = %d\n" | ^~~~ test.c:8:5: note: ‘sprintf’ output between 13 and 1031 bytes into a destination of size 499 Is this the same cause, too?