Skip to content
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

Do not use buf.size() on a uninitialized array. #1085

Closed

Conversation

mgautierfr
Copy link

Recent version of gcc raise a warning maybe-uninitialized when using
size() method on a uninitialized array.
This prevent us to use httplib in a project compiled with -Werror.

This fixes the same problem than #980 but in a better way.
I concentrate myself on the place where gcc raised a warning, not everywhere in the code where we could replace buf.size() by a constant.

Recent version of gcc raise a warning `maybe-uninitialized` when using
`size()` method on a uninitialized array.
This prevent us to use httplib in a project compiled with `-Werror`.
@yhirose
Copy link
Owner

yhirose commented Nov 3, 2021

@mgautierfr, thanks for the feedback, but I don't agree with the warning from gcc. It looks like a false negative to me. I'll google it, and get back to you.

EDIT: I just found the gcc bug report "Bug 101831 - Spurious maybe-uninitialized warning on std::array::size". According to it, I am thinking not to merge this pull request, since other compilers don't emit the incorrect warning at this point. But I would appreciate it if you give me your thought. I am still open to this issue. Thanks!

mgautierfr added a commit to kiwix/libkiwix that referenced this pull request Nov 5, 2021
mgautierfr added a commit to kiwix/libkiwix that referenced this pull request Nov 5, 2021
mgautierfr added a commit to kiwix/libkiwix that referenced this pull request Nov 8, 2021
yhirose added a commit that referenced this pull request Nov 15, 2021
@yhirose yhirose closed this in ec56dfa Nov 15, 2021
@yhirose
Copy link
Owner

yhirose commented Nov 15, 2021

@mgautierfr, I guess i fixed this issue in a better way. Could you check with the latest httplib.h on your machine when you have a chance? Thanks!

@mgautierfr
Copy link
Author

It works on my computer yes. Thanks for the fix.

ExclusiveOrange pushed a commit to ExclusiveOrange/cpp-httplib-exor that referenced this pull request May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants