title: How to evaluate gcc format-overflow checking size 72
body: <p>My sample code (t.c)</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;time.h&gt;
  int main() {
          /* 12345678901234567890
           * 2017/09/06 12:28:30  */
          char wtime[19];
          time_t t=time(NULL);
          struct tm *pt = localtime(&amp;t);
          sprintf(wtime, "%04d/%02d/%02d %02d:%02d:%02d", pt-&gt;tm_year+1900,
              pt-&gt;tm_mon+1, pt-&gt;tm_mday, pt-&gt;tm_hour, pt-&gt;tm_min, pt-&gt;tm_sec);
          printf("%s %ld\n", wtime, sizeof(int));
          return 0;
  }
  </code></pre>
  
  <p>Warning message by <code>gcc -Wall -Wformat=2 -m64 t.c</code> (gcc 7.1.1)</p>
  
  <pre><code>t.c:9:47: warning: ‘sprintf’ writing a terminating nul past the end of the destination [-Wformat-overflow=]
    sprintf(wtime, "%04d/%02d/%02d %02d:%02d:%02d", pt-&gt;tm_year+1900,
                                                 ^
  t.c:9:2: note: ‘sprintf’ output between 20 and 72 bytes into a destination of size 19
    sprintf(wtime, "%04d/%02d/%02d %02d:%02d:%02d", pt-&gt;tm_year+1900,
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        pt-&gt;tm_mon+1, pt-&gt;tm_mday, pt-&gt;tm_hour, pt-&gt;tm_min, pt-&gt;tm_sec);
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  </code></pre>
  
  <p>The number 20 in the message is 19 and one terminator ('\0').
  I am wonder, why there is a number 72? How to evaluate it.  It is not necessary to increase wtime as size 72 in this sample.</p>