Issue 134353
Summary [clang] Missing diagnostic when initializing a member variable using uninitialized member variable
Labels clang
Assignees
Reporter horenmar
    I recently found an `-Wreorder` adjacent issue that does not get diagnosed. In the `test_t` struct below, we initialize `bar` using `foo` member variable, but because `foo` is declared after `bar`, we are reading it before initialization. (this can happen e.g. by reordering the member without noticing the dependency).

```cpp
struct test_t {
  int bar{ foo + 1 };
 int foo{ 3 };
};

int main() {
    test_t t{};
}
```
[CE link](https://godbolt.org/z/W7zMva9x7)

Ideally this would also be caught under `-Wreorder` or by `-Wuninitialized`.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to