Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

M5-3-1: False positives in unevaluated contexts associated with uninstantiated templates #851

Closed
Assignees
lcartey
Labels
Difficulty-LowA false positive or false negative report which is expected to take <1 day effort to addressImpact-Mediumfalse positive/false negativeAn issue related to observed false positives or false negatives.
@lcartey

Description

@lcartey

Affected rules

  • M5-3-1

Description

This rule is reporting false positives in unevaluated contexts associated with uninstantiated templates. For example:

  • noexcept specifiers of functions.
  • static_asserts within template functions (not consistently).

In these cases, the type of the operand of the boolean operator isUnknownType, which is flagged by the query as not boolean.

In principle, we should be able to exclude these cases by specifyingnot operand.isFromUninstantiatedTemplate(_). However, this doesn't apply to e.g.noexcept specifiers. We also see examples wherestatic_asserts for the uninstantiated template are orphaned, and not associated with the uninstantiated template.

The fix is to exclude operands with the typeUnknownType.

Example

template<typename T>constexprbool some_variable_template_v =false;template<>constexprbool some_variable_template_v<int> =true;template<typename S>voidtemplate_with_no_except()noexcept(some_variable_template_v<S> &&true) {// COMPLIANT}voidtest_template() { template_with_no_except<int>(); }

Metadata

Metadata

Assignees

Labels

Difficulty-LowA false positive or false negative report which is expected to take <1 day effort to addressImpact-Mediumfalse positive/false negativeAn issue related to observed false positives or false negatives.

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp