このページでは

到達不可能なコード

この警告カテゴリのスペルは[unreachable-code] です。

到達不能なコード

何が起こりましたか?

あなたのコード内の命令は到達不可能で、決して実行されません。

なぜ悪いのですか?

到達不能なコードはプログラム・ロジックに寄与せず、アプリケーションのディスクとメモリ・フットプリントを肥大化させます。到達不能なコードは、根本的なバグやロジック・エラーの兆候である可能性があります。

function f(b: bool) : string {
    if (b)
        return "true"
    else
        return "false"
    return "something else??" // unreachable statement
}

この警告を修正するには、死んでいる命令を削除するか、コードをリファクタリングしてすべてのロジックを到達可能にしてください。

function f(b: bool) : string {
    if (b)
        return "true"
    else
        return "false"
}

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.