Skip to content

-Wunterminated-string-initialization warning on some kinds of initializations appears to be unactionable #153314

@alexrp

Description

@alexrp
#include <stdint.h>
int main() {
    uint8_t *p = (uint8_t[4]){"\252\273\314\335"};
}
clang test.c -Wunterminated-string-initialization
test.c:3:31: warning: initializer-string for character array is too long, array size is 4 but initializer has size 5
      (including the null terminating character); did you mean to use the 'nonstring' attribute? [-Wunterminated-string-initialization]
    3 |     uint8_t *p = (uint8_t[4]){"\252\273\314\335"};
      |                               ^~~~~~~~~~~~~~~~~~
1 warning generated.

We've already made Zig's C backend use __attribute__((nonstring)) where possible, but in cases like this, it doesn't seem like there's anything we can do?

cc @AaronBallman (#137829)

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzer

    Type

    Projects

    Status

    Needs Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions