JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.

If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.

If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.

CodeSonar® 9.2p0 CONFIDENTIAL CodeSecure Inc
C and C++


LANG.STRUCT.UCTCH : Masked by Handler

要旨

An exception handler will never be executed because an earlier handler catches all its exceptions.

For example, a handler for some type B occurs earlier than a handler for a type D that is derived from B.

Default (ellipsis) handlers that are not last are instead reported as Masked by Default Handler.

プロパティ

クラス名 Masked by Handler
日本語クラス名 Masked by Handler
クラス分類 冗長性 (redundancy)
ニーモニック LANG.STRUCT.UCTCH
カテゴリー
AUTOSARC++14 AUTOSARC++14:M15-3-6 Where multiple handlers are provided in a single try-catch statement or function-try-block for a derived class and some or all of its bases, the handlers shall be ordered most-derived to base class.
MisraC++2008 MisraC++2008:15-3-6 Where multiple handlers are provided in a single try-catch statement or function-try-block for a derived class and some or all of its bases, the handlers shall be ordered most-derived to base class.
CWE CWE:561 Dead Code
  CWE:703 Improper Check or Handling of Exceptional Conditions
CERT-CPP CERT-CPP:ERR51-CPP Handle all exceptions
  CERT-CPP:ERR54-CPP Catch handlers should order their parameter types from most derived to least derived
JSF++ JSF++:186 There shall be no unreachable code.
OWASP-2025 OWASP-2025:A10 Mishandling of Exceptional Conditions
対応言語 C++ のみ利用可能です。 C は利用できません。
有効/無効設定 Checks for this warning class are enabled by default. However, warning instances of this class that are issued as parser errors (rather than parser warnings) will be discarded when using factory configuration settings. To prevent these instances from being discarded, add the following WARNING_FILTER rule to the project configuration file.
WARNING_FILTER += allow class="Masked by Handler"
To disable checks for this warning class, add the following WARNING_FILTER rule to the project configuration file.
WARNING_FILTER += discard class="Masked by Handler"

#include <exception>

class derived_excp : public std::exception {};
class more_derived_excp : public derived_excp {};

namespace lang_struct_uctch{

  void most_to_least(void){
    try {
    } catch ( more_derived_excp ) {
    } catch ( derived_excp ) {                 // ok: base class of more_derived_excp 
    } catch ( std::exception ) {               // ok: base class of derived_excp and more_derived_excp 
    }
  }

  void least_to_most(void){
    try {
    } catch ( std::exception ) {
    } catch ( derived_excp ) {      // 'Masked by Handler' warning issued here
    } catch ( more_derived_excp ) { // 'Masked by Handler' warning issued here
    }
  }

  void excp_ptr(void){
    try {
    } catch ( std::exception* ) {
    } catch ( derived_excp* ) {     // 'Masked by Handler' warning issued here
    }
  }

   void excp_ref(void){
    try {
    } catch ( std::exception& ) {
    } catch ( derived_excp& ) {     // 'Masked by Handler' warning issued here
    }
  }

  void void_ptr(void){
    try {
    } catch ( void*) {
    } catch ( std::exception* ) {   // 'Masked by Handler' warning issued here
    }
  }

  void repeat(void)
  {
      try{
      } catch ( int ) {
      } catch ( int ) {             // 'Masked by Handler' warning issued here
      }
  }

  void ellipsis(void){
    try {
    } catch (...) {
    } catch ( std::exception ) {    // 'Masked by Default Handler' warning issued here
    }
  }

}

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

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

 

To report problems with this documentation, please visit https://support.codesecure.com/.