Skip to content

[clang-tidy] readability-redundant-member-init: flag assignment with std::nullopt #142918

Open
@chrchr-github

Description

@chrchr-github
#include <optional>

struct S {
    std::optional<int> o1 = {};           // warns here, OK 
    std::optional<int> o2 = std::nullopt; // should also warn here, but it doesn't
};
<source>:4:27: warning: initializer for member 'o1' is redundant [readability-redundant-member-init]
    4 |     std::optional<int> o1 = {};
      |

https://godbolt.org/z/jzTcf5rs1

Related: #43786

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions