<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - bad fixit for Wstrncat-size in macro"
   href="http://llvm.org/bugs/show_bug.cgi?id=17200">17200</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>bad fixit for Wstrncat-size in macro
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>nlewycky@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Example:

nlewycky@ducttape:~$ llvm/Debug+Asserts/bin/clang -fsyntax-only strncat-macro.c
In file included from strncat-macro.c:1:
./strncat-hdr.h:6:24: warning: the value of the size argument in 'strncat' is
      too large, might lead to a buffer overflow [-Wstrncat-size]
    (strncat((A), (B), sizeof(A)-strlen(A)), *((A)+sizeof(A)-1) = '\0')
                       ^~~~~~~~~~~~~~~~~~~
./strncat-hdr.h:5:24: note: change the argument to be the free space in the
      destination buffer minus the terminating null byte
    (strncat((A), (B), sizeof(A)-strlen(A)), *((A)+sizeof(A)-1) = '\0')
                       ^~~~~~~~~~~~~~~~~~~
                       sizeof(dtString) - strlen(dtString) - 1
1 warning generated.

Of course writing in "dtString" for macro argument "A" isn't right. Here's the
two-file testcase:

nlewycky@ducttape:~$ cat strncat-macro.c
#include "strncat-hdr.h"

void test() {
  char dtString[64];
  char usecString[64];
  STRSCAT(dtString, usecString);
}

nlewycky@ducttape:~$ cat strncat-hdr.h 
#define strncat(dest, src, n) __builtin_strncat (dest, src, n)
unsigned long strlen(const char *s);

#define STRSCAT(A,B) \
    (strncat((A), (B), sizeof(A)-strlen(A)), *((A)+sizeof(A)-1) = '\0')</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>