メインコンテンツ

このページの内容は最新ではありません。最新版の英語を参照するには、ここをクリックします。

MISRA C++:2008 Rule 15-5-2

Where a function's declaration includes an exception-specification, the function shall only be capable of throwing exceptions of the indicated type(s).

説明

ルール定義

Where a function's declaration includes an exception-specification, the function shall only be capable of throwing exceptions of the indicated type(s). 1

Polyspace 実装

チェッカーは、スローされた例外のデータ型が関数仕様にリストされている例外の型に一致しない状況にフラグを設定します。

次に例を示します。

void goo ( ) throw ( Exception )
  { 
    throw 21; // Non-compliant - int is not listed
  }    

チェッカーは、関数本体内にある throw ステートメントに検出を限定します。関数で別の関数が呼び出されていても、チェッカーはその呼び出された関数で例外がスローされているかどうかを検出しません。

チェッカーは、catch ブロック内の throw ステートメントを検出しません。

トラブルシューティング

ルール違反が想定されるものの、Polyspace® から報告されない場合は、コーディング規約違反が想定どおりに表示されない理由の診断を参照してください。

チェック情報

グループ: Exception Handling
カテゴリ: 必要

バージョン履歴

R2013b で導入


1 All MISRA coding rules and directives are © Copyright The MISRA Consortium Limited 2021.

The MISRA coding standards referenced in the Polyspace Bug Finder™ documentation are from the following MISRA standards:

  • MISRA C:2004

  • MISRA C:2012

  • MISRA C:2023

  • MISRA C++:2008

  • MISRA C++:2023

MISRA and MISRA C are registered trademarks of The MISRA Consortium Limited 2021.