- Notifications
You must be signed in to change notification settings - Fork70
Closed
Description
Affected rules
M5-3-1
Description
This rule is reporting false positives in unevaluated contexts associated with uninstantiated templates. For example:
noexceptspecifiers 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>(); }