-
Notifications
You must be signed in to change notification settings - Fork 274
Return value removal: handle missing declarations more gracefully #5671
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
Conversation
Codecov ReportBase: 78.25% // Head: 78.26% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## develop #5671 +/- ##
========================================
Coverage 78.25% 78.26%
========================================
Files 1642 1642
Lines 189749 189757 +8
========================================
+ Hits 148487 148505 +18
+ Misses 41262 41252 -10
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like the test could be further developed to show what happens when you actually call this / where this goes wrong. The "VERIFICATION SUCCESSFUL" is technically correct but I feel like it is almost a bit in bad faith. How about:
void a()
{
int b = c(); // Uses the implicit signature of undefined functions: int c(void)
assert(b == 0);
}
void c(void)
{
// Actually... don't return anything
// So the results will be non-deterministic
}
int main(int argc, char **argv) {
a();
return 0;
}
523fed3
to
6de4be5
Compare
Thank you - shamelessly took this code verbatim to replace the regression test. |
6de4be5
to
0fc88d6
Compare
0fc88d6
to
3e1c93c
Compare
If a function is used before it is defined, a signature of int f(void) is assumed. Then trying to use the (possibly non-existent) return value fails during return-statement removal. In such cases, just assume a non-deterministic value is being returned. Found by running C-Reduce on a CSmith-generated example.
3e1c93c
to
05e5be3
Compare
Should this become a hard error in C99/C11? Clang won't have it. |
If a function is used before it is defined, a signature of int f(void)
is assumed. Then trying to use the (possibly non-existent) return value
fails during return-statement removal. In such cases, just assume a
non-deterministic value is being returned.
Found by running C-Reduce on a CSmith-generated example.