Skip to content

[clang-tidy] False positive for modernize-avoid-c-arrays in smart pointers and their make functions #132260

Open
@kuzi117

Description

@kuzi117

Clangd version: 19.1.2

Using the T[] specialization for make_unique/make_unique_for_overwrite and the resulting unique_ptr, clang-tidy reports that the template parameter should be replaced with std::array.

Example:

  std::unique_ptr<T[]> W = std::make_unique<T[]>(n);
  std::unique_ptr<T[]> X = std::make_unique_for_overwrite<T[]>(n);
  std::shared_ptr<T[]> Y = std::make_shared<T[]>(n);
  std::shared_ptr<T[]> Z = std::make_shared_for_overwrite<T[]>(n);

Every instance of T[] in the example is flagged as violating cppcoreguidelines-avoid-c-arrays/modernize-avoid-c-arrays and suggests using std::array instead, which doesn't seem feasible in the context.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions