-
-
Notifications
You must be signed in to change notification settings - Fork 360
Fixing C warnings #934
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
Fixing C warnings #934
Conversation
It seems that, actually, I have done immediately exactly what I have said I would not do. Anyway, I did 1 commit per algorithm fix, so that reverting is easier. I can tell there is probably something wrong on the Gaussian elimination algorithm because I could completely eliminate the The rest of the fixes are simply fiddling around between |
Does this mean that Gaussian is wrong as a whole? |
I have not checked the correctness of the code yet, so I can't answer properly. It's just that, intuitively, there's something wrong if you're able to not pass one of the dimensions of the matrix. EDIT: Also, I did not run the executables. Seeing how it's coded, the Gaussian elimination is probably going to segfault if we step outside the assumptions that were made. |
Removed useless cast to (size_t *) in stable_marriage
Okay, I think I know the basic assumption of the Gauss-Jordan algorithm's implementation. We assume that we have an |
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.
Hi, thanks for the fixes!
Overall the changes look good to me, however there is a small typo in the gaussian elimination code.
Apart from that, it is ready to be merged.
@@ -50,7 +50,7 @@ void gaussian_elimination(double *a, const size_t rows, const size_t cols) { | |||
void back_substitution(const double *a, double *x, const size_t rows, | |||
const size_t cols) { | |||
|
|||
for (int i = rows - 1; i >= 0; --i) { | |||
for (size_t i = rows - 1; i == 0; --i) { |
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.
This needs to be i >= 0, otherwise the loop body will never be executed
Fixed a dumb error.
Currently, no warnings are activated during compilation for C.
Because of this, the code might be inconsistent in certain places.
I aim to fix or remove some errors in the C code, depending on if we consistently violate warnings or not.
Currently, only the following algorithms build without warnings:
The main errors I see in the rest of them are
sign-compare
,unused-parameter
andunused-variable
, along with aimplicit-function-declaration
and tworeturn-type
.I did not implement any changes to the code yet, but I'll do that in the following days (hence why it's a draft PR).