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.0p0 Hot Tips | CONFIDENTIAL | CodeSecure Inc |
An exception handler will never be executed because an earlier handler catches all its exceptions.
There are three possible cases.
| クラス名 | Unreachable Catch | |||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 日本語クラス名 | Unreachable Catch | |||||||||||||||||||||||||||
| クラス分類 | 冗長性 (redundancy) | |||||||||||||||||||||||||||
| ニーモニック | LANG.STRUCT.UCTCH | |||||||||||||||||||||||||||
| カテゴリー |
|
|||||||||||||||||||||||||||
| 対応言語 | C++ のみ利用可能です。 C は利用できません。 |
|||||||||||||||||||||||||||
| 有効/無効設定 | このワーニングクラスのチェックはデフォルトで無効になっており、プロジェクトには非正規の C向けAST
が必要になります。有効にするにはプロジェクト設定ファイル (configuration file) に以下の WARNING_FILTER ルールと
RETAIN_UNNORMALIZED_C_AST 設定を追加してください。
RETAIN_UNNORMALIZED_C_AST = Yes WARNING_FILTER += allow class="Unreachable Catch" |
#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 ) { // 'Unreachable Catch' warning issued here
} catch ( more_derived_excp ) { // 'Unreachable Catch' warning issued here
}
}
void excp_ptr(void){
try {
} catch ( std::exception* ) {
} catch ( derived_excp* ) { // 'Unreachable Catch' warning issued here
}
}
void excp_ref(void){
try {
} catch ( std::exception& ) {
} catch ( derived_excp& ) { // 'Unreachable Catch' warning issued here
}
}
void void_ptr(void){
try {
} catch ( void*) {
} catch ( std::exception* ) { // 'Unreachable Catch' warning issued here
}
}
void ellipsis(void){
try {
} catch (...) {
} catch ( std::exception ) { // 'Unreachable Catch' warning issued here
}
}
}
設定ファイルの以下のパラメータがこのワーニングクラスのチェックに影響します。