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
Turn on extra warnings on GCC #67733
Comments
What if make GCC emit extra warnings? Adding following options: -Wall -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers will make GCC emit all warnings except few types that would produce too many warnings. With these options the compilation is almost clean on 32-bit Linux. |
+1. I think the flags should go into CFLAGS_NODIST. |
I'm not well experienced with autoconf. Here is my attempt. |
Could anyone please make a review? |
-Wall is already added (unconditionally) to $OPT above. What’s the point of also adding it to $CFLAGS_NODIST as well? Does it have to be added to both? |
The proposed options add exactly one warning for me (ignoring warnings from libffi). How would you work around this: ./Include/pymem.h:136:18: warning: comparison is always false due to limited range of data type [-Wtype-limits] |
Just add -Wno-type-limits. |
I don't think adding -Wno-type-limits is a good idea. The good question is how that can be happening, e.g. how PY_SSIZE_T_MAX divided by sizeof anything can be *more* than max(size_t)? E.g now that I stare at the code, *that* warning should be impossible if everything is correct. It means either that the RHS is negative or size_t is defined to be 32-bit in this compilation unit whereas PY_SSIZE_T is 64-bit. Neither sound like a good idea. |
I didn’t look too closely, but I did see that _ssl_locks_count is unsigned int. I was compiling for x86-64 Linux, where int is 32 bits and size_t is 64. So maybe GCC was optimizing the (size_t) cast away, and then rightfully warning that the largest unsigned int will never exceed the largest possible array size. |
Seems GCC is such smart, that can deduce that the maximal value of _ssl_locks_count is never larger than PY_SSIZE_T_MAX / sizeof(PyThread_type_lock). The other workaround is making _ssl_locks_count of type size_t instead of unsigned int, but I wouldn't do this with good reasons. |
Ah, indeed, I somehow missed that. Though, there is no good reason for it being unsigned either; as the actual type in SSL API's is of type int. Another argument of type int is cast to unsigned just for the comparison on line 4419, and unsigned int counters i and j are used in function _setup_ssl_threads. The variable could be safely changed to |
Rebased patch. Removed save_CFLAGS="$CFLAGS" and CFLAGS="$save_CFLAGS" lines as Marin suggested. Benjamin, seems you are experienced with autoconf. Could you please make a review? |
Can one of the -Wall flags be dropped? What is the difference between $OPT and $CFLAGS_NODIST? gcc -pthread -c -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -std=c99 -Wall -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -I. -IInclude -I./Include -DPy_BUILD_CORE -o Programs/python.o ./Programs/python.c |
New changeset 99adb5df8cb6 by Serhiy Storchaka in branch 'default': |
AFAIK $CFLAGS_NODIST is used only for compiling the core and standard modules, $OPT is included in $CFLAGS and also used for compiling third-party extensions. Since -Wall is already included in $OPT, there is no need of it in $CFLAGS_NODIST. Removed this part. Thank you for your review Martin. |
The commit didn't resolve the warning though. |
All warnings were resolved at the moment of providing previous version, but the code was changed too much last days. New warnings was added and disappeared in these days. Now we can just sit and resolve the leftover. |
New changeset da485c6c744e by Stefan Krah in branch 'default': |
Agreed. SilentGhost, it's probably best to open new issues for the warnings. |
I think Silent Ghost is talking about my -Wtype-limits warning, which is still present. That is the only warning I am getting. I suspect you won’t see it with a 32-bit build. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: