llvm / llvm/llvm-project

`performance-noexcept-move-constructor` does not fire in some cases

Open
#195,637 1 comment 0 reactions 0 assignees View on GitHub
clang-tidy false-negative
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

The performance-noexcept-move-constructor warning does not fire for the move constructor when that constructor is explicitly invoked in the code:
https://godbolt.org/z/37GhMErGh

Additionally, the warning does not fire for the move assignment operator (operator=) when, together with a variable whose move constructor and move assignment operator are not noexcept, std::vector<...> is used (https://godbolt.org/z/sfxPehdh4).

Notably, std::vector must be declared above the problematic variable.

Example where the warning does NOT trigger:
```
std::vector cache_;
Value value; // warning does NOT appear
```

Example where the warning DOES trigger (as expected):
```
Value value; // warning appears
std::vector cache_;
```

https://godbolt.org/z/fqrhf4v6q
https://godbolt.org/z/f6b8h6e81

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the explicit move-constructor and move-assignment cases in the linked Compiler Explorer examples, then trace the performance-noexcept-move-constructor check in the LLVM project. Done means the check warns in both cases, including when std::vector is declared before the problematic variable, without changing the expected warning behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.