Issue 52818
Summary cppcoreguidelines-prefer-member-initializer: bad fix-it for delegating constructor
Labels clang-tidy
Assignees
Reporter sfc-gh-sgiesecke
    `cppcoreguidelines-prefer-member-initializer` produces a bad fix-it for delegating constructor that set member in their body, e.g.
```
struct Foo  {
    Foo() = default;
    Foo(int) : Foo() { m_bar = 3; }

    int m_bar;
};
```

The suggested fix-it would rewrite this as:
```
    Foo(int) : Foo(), m_bar(3) {}
```
which is invalid.

See https://godbolt.org/z/Yvb1ovnsr

In fact, it doesn't seem it makes sense for the rule to diagnose this case at all. While this may be considered bad style, it can't be easily changed without introducing a new constructor overload.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to