正在阅读GCC 6 发行版系列更改、新功能和修复我发现这个新选项非常有趣-Wmisleading-indentation
:
-Wmisleading-indentation warns about places where the indentation of the code
gives a misleading idea of the block structure of the code to a human reader.
For example, given CVE-2014-1266:
sslKeyExchange.c: In function 'SSLVerifySignedServerKeyExchange':
sslKeyExchange.c:631:8: warning: statement is indented as if it were guarded by... [-Wmisleading-indentation]
goto fail;
^~~~
sslKeyExchange.c:629:4: note: ...this 'if' clause, but it is not
if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0)
^~
tab space
我只是想知道当缩进是“未知”时,该选项如何识别可靠的此类误导性缩进,gcc
因为它可以是 4 或 8 甚至任何......
答案1
不可以。开发商明确说明它基于一组启发式算法来捕捉最多没有太多噪音的误导性压痕。与其他编译器警告一样,会出现误报和漏报。让当前的GCC 对大多数代码都松散,-Wall
并且会哭泣。