New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Octal literals, e.g. 'int i = 010;' are arguably evil #227
Comments
Original comment posted by cgdecker@google.com on 2014-01-16 at 09:57 PM They're kind of useful when converting between numeric POSIX file permissions and other formats, though I admit that's very much an edge case. |
Original comment posted by eaftan@google.com on 2014-03-04 at 12:52 AM We found many legitimate uses of octal literals for file permissions, and many illegitimate uses for dates. We could possibly special case the checker to allow octal literals that are passed into file-permission-accepting methods. Status: Accepted |
/cc @kevinb9n
I'm going to update the prototype check to only flag octal values that are not of length 2 or 4. That should weed out these legitimate cases. |
I special cased my prototype checker to flag octal values that are not of length 2 or 4, to avoid the date and filesystem permissions false positives, but most of the hits were still false positives. I think octal literals may not actually be evil. Closing as will not fix. |
Okay then. Good to know. Thanks for digging into it. On Tue, Jan 27, 2015 at 9:16 PM, Eddie Aftandilian <notifications@github.com
Kevin Bourrillion | Java Librarian | Google, Inc. | kevinb@google.com |
Original issue created by kevinb@google.com on 2014-01-16 at 07:09 PM
I just finished swearing up and down that the integer literal 010 would equal ten, not eight. How embarrassing.
If we have managed to get the 'l' suffix error to work, it might be worth considering a check that forbids all octal literals as well.
The text was updated successfully, but these errors were encountered: