C and C++


MATH.TYPE.TGMATH.ITA : Inconsistent Types of Arguments to <tgmath.h> Macro

要旨

A multi-argument type-generic macro from <tgmath.h> is used with operand arguments of different standard types.
The relevant macros are: atan2, copysign, fdim, fma, fmax, fmin, fmod, frexp, hypot, ldexp, nextafter, nexttoward, pow, remainder, remquo, scalbn, scalbln

プロパティ

クラス名 Inconsistent Types of Arguments to <tgmath.h> Macro
日本語クラス名 Inconsistent Types of Arguments to <tgmath.h> Macro
クラス分類 信頼性 (reliability)
ニーモニック MATH.TYPE.TGMATH.ITA
カテゴリー
MisraC2023 MisraC2023:21.23 All operand arguments to any multi-argument type-generic macros declared in <tgmath.h> shall have the same standard type
Misra2012 Misra2012:21.23 All operand arguments to any multi-argument type-generic macros declared in <tgmath.h> shall have the same standard type
対応言語 C および C++ で利用可能です。
有効/無効設定 このワーニングクラスのチェックはデフォルトで無効になっており、プロジェクトには非正規の C向けAST が必要になります。有効にするにはプロジェクト設定ファイル (configuration file) に以下の WARNING_FILTER ルールと RETAIN_UNNORMALIZED_C_AST 設定を追加してください。
RETAIN_UNNORMALIZED_C_AST = Yes
WARNING_FILTER += allow class="Inconsistent Types of Arguments to <tgmath.h> Macro"
注:非正規化された AST を継続して使用した場合、使用ディスク容量が増加し解析時間が長くなる可能性があります。

#include <tgmath.h>

float call_atan2(unsigned int u, int i){
    float rv = 0;
    rv += (float) atan2(u, i); /* 'Inconsistent Types of Arguments to <tgmath.h> Macro'
                                *  warning issued here: one operand argument is unsigned int
                                *  and the other is int
                                */
    rv += (float) atan2((float)u, (float)i);          /* ok: both operand arguments are float */
    return rv;
}


int call_rexp(float f){
    int i;
    (void) frexp(f, &i);                              /* ok: second parameter to frexp() is not an operand */
    return i;
}

関連のある設定ファイルパラメータ

設定ファイルの以下のパラメータがこのワーニングクラスのチェックに影響します。