title: -Wformat-truncation - can I avoid it rather than disable the warning?
body: <p>There's this code I'm compling, which has the line:</p>
  
  <pre><code>snprintf(target, 11, "%02ld-%02ld-19%02ld", day, month, year);
  </code></pre>
  
  <p>... which is executed after it has been verified that all 3 values are valid; and specifically, that year is between 0 and 99.</p>
  
  <p>However, recent versions of GCC, when run with <code>-Wextra</code>, complain:</p>
  
  <pre><code>warning: ‘%02ld’ directive output may be truncated writing between 2 and 20 bytes
  into a region of size 3 [-Wformat-truncation=]
  </code></pre>
  
  <p>I would rather not entirely disable this warning; nor even disable it locally. Instead, I am wondering if I could somehow "convince" GCC of the value range for the three arguments, preventing the warning.</p>
  
  <p><sub>Yes, this is rather ugly code that reinvents the wheel, and locale-specific routines for date formatting should be used, no need to lecture me; not my code.</sub></p>