-
Notifications
You must be signed in to change notification settings - Fork 10.7k
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
[clang-tidy] create a check that looks for constructing a string from a nullptr #92061
Comments
@llvm/issue-subscribers-clang-tidy Author: Richard Thomson (LegalizeAdulthood)
Consider the following code:
This code compiles just fine with no warnings or errors, but crashes when you run it. We should be able to detect cases where a |
Hi! This issue may be a good introductory issue for people new to working on LLVM. If you would like to work on this issue, your first steps are:
If you have any further questions about this issue, don't hesitate to ask via a comment in the thread below. |
@llvm/issue-subscribers-good-first-issue Author: Richard Thomson (LegalizeAdulthood)
Consider the following code:
This code compiles just fine with no warnings or errors, but crashes when you run it. We should be able to detect cases where a |
Caught by
|
Hi @chrchr-github, |
Not sure what there is to do, with two checks already reporting the issue... |
Then I would say we don't need a third check ;) |
which two checks report the issue? |
oic now github mobile wasn't showing all the comments (how unhelpful!) |
Consider the following code:
See compiler explorer example
This code compiles just fine with no warnings or errors, but crashes when you run it. We should be able to detect cases where a
nullptr
is used to construct a string, at least in the simple case above. I had a real-world bug that was exactly the above scenario, although I have simplified the example to remove irrelevant code. Obviously more sophisticated data flow analysis can propagatenullptr
through usages until it hits astd::basic_string
constructor, but even detecting the above simple case would be a useful start.Note: there are several constructor overloads that take a pointer to a character as an argument and they are all invalid if the pointer is
nullptr
.The text was updated successfully, but these errors were encountered: