Skip to content

[clang-tidy] 🐛 std::vector(size, value) in modernize-return-braced-init-list #68159

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ax3l opened this issue Oct 3, 2023 · 1 comment · Fixed by #68491
Closed

[clang-tidy] 🐛 std::vector(size, value) in modernize-return-braced-init-list #68159

ax3l opened this issue Oct 3, 2023 · 1 comment · Fixed by #68491
Assignees

Comments

@ax3l
Copy link

ax3l commented Oct 3, 2023

Description

The clang-tidy pass modernize-return-braced-init-list complains about constructors of std::vector that are not initializers lists.

In particular, the constructor

vector( size_type count,
                 const T& value,
                 const Allocator& alloc = Allocator() );

should be ignored.

Versions Affected

Bug seen with LLVM 14.

Reproducer

#include <vector>

std::vector<double>
foo()
{
    return std::vector<double>(4, 5);  // {5, 5, 5, 5}

}

https://en.cppreference.com/w/cpp/container/vector/vector

X-Ref

BLAST-WarpX/warpx#4338

Keywords

  • clang-tidy
  • clang-tools-extra
@5chmidti
Copy link
Contributor

5chmidti commented Oct 3, 2023

Just confirming that the current trunk version is affected as well: https://godbolt.org/z/xcen5GojE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants