<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/150951>150951</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [Clang] Attribute gnu::nonstring should apply to char * variables
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          d-musique
      </td>
    </tr>
</table>

<pre>
    Hi, when `[[gnu::nonstring]]` is applied to a variable of type `char *`, clang reports this as unsupported.
However, this functionality works on gcc and it is useful.
This is on clang 21.1.0-rc1.

`warning: 'gnu::nonstring' attribute only applies to fields or variables of character array type; type is 'char *' [-Wignored-attributes]`

This is the minimal example:

```
#include <string.h>
#include <stddef.h>

typedef struct
{
    [[gnu::nonstring]] char *data; /* no clang support */
 size_t size;
} Thing;

size_t foo(Thing *x)
{
    return strlen(x->data); /* warns on gcc */
}
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJx8k8uO6ygQhp8Gb0qxMMRxsvDCSTrqB2hpliNsyjYzBDxcks48_Qhy6R6d1pGQLJm6_N9fhfBeTQaxJfWe1MdCxDBb18rVOXr1T8Sit_LWvivCDnCd0QDZ0By6n0wkvCO8M9b44JSZSH1MZ0NBeRDLohVKCBYEXIRTotcIdoRwWzBVGWbhgLAuFWQHGLQwEzhcrAsewpxKeIjGxyX9QlkS2r3bK17QpfgcMUYzBGWN0Crc4Grd3x6sgWkYQBgJKiQl0eMYdUr_SDkqh9zbsaqsSrpyQ5Wu09nQq3AmwfAOCGt-oGQNiBCc6mNAsEbfHqw-sY4KtfRg3YvZJ-gEK4aADoRz4pZNIHx_N0P51OnlB2uA1PvVH2oy1qFcvZr5u7t3pU-WMCOclVFnoQE_xXnRmAQ_aR6HdoRxZQYdJQLhhztKORP-9sOdlDi-7miXREocwQcXh5D-NXtCOwCA368CPJmkCCLhEnYirANjH_4_hnvHPqWaXv2Lf4b8IXyfex3hY84D2d_lPEJGawnb5quU_0nY7n_SHIboTBKt0RC2_VwR_paFsN03LWncr6V56SDN8bt_hWy53PGdKLCtmpo3dMeruphb5BWTWG22I4r1iFUtd5XYClzLZtyOvShUyyiracO2FWdbXpe0rkTVjw3t64Gv6ZqsKZ6F0qXWl3Np3VQo7yO2VU13dVVo0aP2-XUylk0jjKWH6tqUsOrj5MmaauWD_yoRVND5SR9yRn2E7rWxvw4L_GyjlnmNb2mJn2P72uEiOt3OISw-5SbnTpMKc-zLwZ4JO6XOj89qcfYvHAJhp0ziCTs9YC4t-y8AAP__1Tliog">