Skip to content

[clang-tidy] performance-noexcept-move-constructor and performance-noexcept-swap do not handle conditional noexcept properly #68101

Closed
@jpboivin

Description

@jpboivin

Hello,

I've tested clang-tidy 17 on some codebases, and there seems to be false positives (except if I'm missing something) with performance-noexcept-move-constructor and performance-noexcept-swap checks, at least in templated code that annotates the move constructor or swap with a conditional noexcept (when using traits, otherwise it is properly handled).

I've written an extremely simple piece of code that triggers the issue:
https://godbolt.org/z/59EhaEeda

[<source>:7:37: warning: noexcept specifier on the move constructor evaluates to 'false' [performance-noexcept-move-constructor]]
    7 |     Container(Container&&) noexcept(std::is_nothrow_move_constructible_v<T>);
      |                                     ^
[<source>:8:42: warning: noexcept specifier on swap function evaluates to 'false' [performance-noexcept-swap]]
    8 |     void swap(Container& other) noexcept(std::is_nothrow_swappable_v<T>);
      |                                          ^
2 warnings generated.

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