Issue 150951
Summary [Clang] Attribute gnu::nonstring should apply to char * variables
Labels clang
Assignees
Reporter d-musique
    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 */
}
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to