https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124183
Bug ID: 124183
Summary: Erroneous -Wformat-truncation= warning using -O3
Product: gcc
Version: 15.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: woughter.dominick at gmail dot com
Target Milestone: ---
Created attachment 63733
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=63733&action=edit
main.cpp
Compiling this code produces strange warnings as described in the source code:
```
main.cpp:11:13: warning: null destination pointer [-Wformat-truncation=]
11 | snprintf(cstr, 20, "%i", i); // should be safe
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~
```
^ after safely allocating malloc'ing 20 bytes.