Issue 115347
Summary Unsafe buffer usage: constructing [[clang::unsafe_buffer_usage]] fields are not warned on
Labels clang:diagnostics
Assignees
Reporter danakj
    Similar to https://github.com/llvm/llvm-project/issues/80482 but splitting this off as it's about fields annotated with `[[clang::unsafe_buffer_usage]]`.

Godbolt example: https://godbolt.org/z/9v9EsPej6
```cc
struct S {
 [[clang::unsafe_buffer_usage]] int i;
};

class C {
public:
 C() : i(1) {}  // no error?
    C(int j) : i(j) {}  // no error?
private:
    [[clang::unsafe_buffer_usage]] int i;
};

int main(){
    S s = { .i = 1 };  // no error?
    s.i = 2;  // error ^_^b
    S s2(1);  // no error?
    C c;
    C c2(1);
}
```

In the above example only `s.i = 2` causes an unsafe-buffer-usage warning. Constructing a type with `[[unsafe_buffer_usage]]` fields does not produce any warning.

cc: @haoNoQ @ziqingluo-90
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to