Skip to content

misc-const-correctness does not warn when using auto to declare local variables #60789

@ChrisThrasher

Description

@ChrisThrasher
void foo() { bool a = true; // recommends adding const auto b = true; // no diagnostic emitted }

When declaring a local variable with auto, misc-const-correctness will never recommend adding const. I've tried this for built-in types as well as user-defined types and can't under any circumstances get it to recommend adding const to an auto type.

I was able to observe this with clang-tidy v15.0.7 as distributed by Homebrew.

EDIT: See https://reviews.llvm.org/D145856

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