-
Notifications
You must be signed in to change notification settings - Fork 25
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
Achieve and enforce warning-free builds with GNU -Wall -Werror in CI #300
Comments
I am still getting warnings when I build like this: cmake -DTEST_FILE_DIR=/home/ed/bufr -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=/usr/local/NCEPLIBS-sp.2.4.0 -DENABLE_DOCS=ON .. && make VERBOSE=1 && make test For example: cd /home/ed/b2/b/src && /usr/bin/gfortran -DLITTLE_ENDIAN -I/home/ed/b2/b/src -I/home/ed/b2/src -g -fbacktrace -ggdb -Wall -O0 -Jinclude/bufr_4 -fPIC -c /home/ed/b2/src/copymg.f -o CMakeFiles/bufr_4_f.dir/copymg.f.o 85 | SUBSET = TAG(INODE(LIN)) and cd /home/ed/b2/b/src && /usr/bin/gfortran -DLITTLE_ENDIAN -I/home/ed/b2/b/src -I/home/ed/b2/src -g -fbacktrace -ggdb -Wall -O0 -Jinclude/bufr_4 -fPIC -c /home/ed/b2/src/cpymem.f -o CMakeFiles/bufr_4_f.dir/cpymem.f.o 83 | SUBSET = TAG(INODE(LIN)) OK, the problem is that in the developer workflow, we are not using -Wall:
|
OK, one problem was that I was using gcc-9 and gfortran-9. When I switch to 11 or 12 I get no warnings. |
But one thing I notice is that we don't need this: -fallow-invalid-boz |
The -Wall was already being included by the -DCMAKE_BUILD_TYPE=Debug. I have upgraded the developer build to gcc-11/gfortran-11. Using 12 causes gcovr to break! I have removed the unneeded invalid boz flag. We are still covering many warnings with the -fallow-argument-mismatch flag. Can we remove it? |
I honestly have no idea. I wasn't the one who put it there in the first place, so I'm not sure what it may or may not still be covering. I guess the only way to find out would be to try removing it and see what happens(?) |
Yes, I am working on these flags now, and keeping notes in this issue. ;-) Kyle and I were the ones who put this flag in everywhere. It was required because gfortran-10 and later started complaining about mismatched arguments in code, and that was a common practice in our code. But it should not be, so we should strive to match all our arguments and remove this flag. However, what is even more interesting is we are using the '-w' flag, and I don't know what that is. When I remove it, we get a lot of warnings that I also get when using gfortran-9. In other words, -w is turning off some warnings. These look easier than the mismatched arguments, so lets work on them first. |
Here's the first set of warnings encountered after I remove the -w flag.
These look like the kind of warnings we want to find and want to fix. In the above case, these warnings can be fixed by explicitly using the int() function to covert to int, instead of relying on automatic conversion. |
OK, this is now fixed in #406. The VALX routine was only ever being used to decode integers anyway, so I upgraded STRNUM to handle all of the cases that VALX had been doing, and I've now completely removed VALX from the library. |
OK, if you remove -w from the GNU fortran flags in the top-level makefile, you will see some warnings. Here's some:
and
and
and
and
|
I've got everything done now so that we can remove the -w flag, and I'll push up a PR within the next hour. The only thing that's still warning is the following line in outtest8.F90, and for the life of me I can't figure out why:
This sort of conversion works fine inside of the library (in the src directory) to get rid of the same warning in numerous places, but for whatever reason it doesn't work here in this one test code. I've tried a number of hacks and variations to try to get around this, including declaring a separate integer*4 variable nwrd, and then calling x84 with lenbmg as input and nwrd as output and then just setting nbyt=nwrd*8. But this still leads to the same warning:
which makes no sense to me b/c I honestly have no idea why the compiler would think that either nbyt or nwrd was an integer*8 value in this situation. For now, I'm just going to hardcode a workaround into outtest8.F90 with a note referring to this issue, and hopefully we can get to the bottom of it at some point. But this way we can at least move forward with turning off the -w flag in CMakeLists.txt. |
Can we close this issue now? |
I had left this open b/c of the lingering issue in outtest8.F90 that's still unresolved. But as I noted, there is a workaround in place, and the issue is documented inside of the test code, so I guess we can go ahead and close this now. |
Is there a CI run with GNU compilers using -Werror -Wall? If so, I don't see it. We need to have a warning check in place. |
Rest assured this is already being done, albeit indirectly so admittedly it can be a bit confusing :-) Specifically, the developer.yaml CI run has the following in its build step:
There are two relevant points here. First off, you can see where the for C:
for Fortran:
So bottom line, both the |
We can turn on full warning checks in GNU gfortran and then clear all warnings.
Then we can turn on -Werror and ensure that no code with warnings gets committed to the repo.
The text was updated successfully, but these errors were encountered: