-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Open
Labels
clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzer
Description
I was kinda surprised that return 1 / 2; produces no warnings, even with -Weverything. That feels like a natural way to write one half, for someone who isn't thinking of integers and truncating division. And since it seems like you would never intentionally write that[0], it should have a warning. I know there are already some warnings where arithmetic with constants doesn't evaluate to the numeric result (eg due to overflow) and this seems to fit right in there. It could even become a single warning about any time that numeric results aren't preserved (excluding bitwise operators and common patterns like -1ull to get a bunch of 1 bits).
[0] Ignoring obfuscated code contests...
Metadata
Metadata
Assignees
Labels
clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzer