Skip to content

__attribute__((nonstring)) and -Wunterminated-string-initialization #137705

@frobtech

Description

@frobtech

GCC has -Wunterminated-string-initialization and __attribute__((nonstring)) to counteract it.
The warning is included in -Wextra.

It warns for e.g. char foo[3] = "foo"; because the string will not have a '\0' terminator.
It doesn't warn for __attribute__((nonstring)) char foo[3] = "foo";.

This would be a useful feature to add to Clang.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerenhancementImproving things as opposed to bug fixing, e.g. new or missing feature

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions