Skip to content

Fix warnings and remove VLA on C++ Thomas algorithm #932

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

Merged
merged 3 commits into from
Jan 15, 2022

Conversation

ShadowMitia
Copy link
Contributor

This PR fixes warnings generated by the code, and removes a variable length array which is not legal in C++ (it's a compiler extension, which most of them do have, but is not strictly speaking C++).

I've also constified and added references where I thought it would be best applicable.

The only part I'm not sure of is :

for (int i = static_cast<int>(size) - 2; i >= 0; --i) {

and my use of the static_cast. size is a std::size_t and we can't just have i be one too (or any unsigned) because of overflow issues which would break the condition. I'm not sure what's the best thing to do in this scenario.
My guess is it's generally fine, and you should only be worried on very large arrays. Which is not the point here.

@ShadowMitia ShadowMitia changed the title Fix warnings and remove VLA Fix warnings and remove VLA on C++ Thomas algorithm Nov 11, 2021
@Amaras Amaras added Implementation Edit This provides an edit to an algorithm implementation. (Code and maybe md files are edited.) lang: c++ C++ programming language labels Nov 27, 2021
Copy link
Member

@leios leios left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. Happy to merge it in!

@leios leios merged commit 7acfce9 into algorithm-archivists:main Jan 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Implementation Edit This provides an edit to an algorithm implementation. (Code and maybe md files are edited.) lang: c++ C++ programming language
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants