在「Useful GCC warning options not enabled by -Wall -Wextra」這邊提到 GCC 如果把這些參數放入 -Wall
與 -Wextra
裡會產生出太多的誤判,但有些參數還是很有用。
不過這邊介紹的參數蠻多都需要 GCC 6+ 甚至 GCC 7+,翻了 Ubuntu 16.04 是 GCC 5.4。
這是文章介紹的參數的整理:
-Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wrestrict -Wnull-dereference -Wold-style-cast -Wuseless-cast -Wjump-misses-init -Wdouble-promotion -Wshadow -Wformat=2
另外一個比較特別的問題是,其實愈來愈多專案搬到 clang 上,這幾年可以看出能量的消長蠻明顯的...
> 這邊提到 GCC 開 -Wall 與 -Wextra 會產生出太多的誤判
這不是原文的文意吧?
"There are many additional warning options that are not enabled by -Wall -Wextra as they may produce too many false positive warnings or be targeted to a specific obscure use case"
是說有很多 warning 就算有 -Wall 和 -Wextra 也沒開,只所以不開是因為這些 warning 可能有太多誤判或者針對太特殊的用途。
yeah 你說的是對的,我來改...