torognes / swarm

A robust and fast clustering method for amplicon-based studies
GNU Affero General Public License v3.0
123 stars 23 forks source link

GCC warnings when using `-Wextra` #99

Closed frederic-mahe closed 7 years ago

frederic-mahe commented 7 years ago

I think we should add -Wextra to swarm's Makefile. Here is the output of GCC 6.3:

algod1.cc: In function ‘void process_seed(int, int)’:
algod1.cc:471:23: warning: unused parameter ‘seed’ [-Wunused-parameter]
 void process_seed(int seed, int subseed)
                       ^~~~
algod1.cc: In function ‘void mark_light_thread(long int)’:
algod1.cc:950:29: warning: unused parameter ‘t’ [-Wunused-parameter]
 void mark_light_thread(long t)
                             ^
algod1.cc: In function ‘void check_heavy_thread(long int)’:
algod1.cc:977:30: warning: unused parameter ‘t’ [-Wunused-parameter]
 void check_heavy_thread(long t)
                              ^
lczech commented 7 years ago

You might also want to try -Wpedantic, to get "clean" ISO code. See here for details: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html

frederic-mahe commented 7 years ago

Hi @lczech, adding -Wpedantic reports two additional warnings:

search8.cc: In function ‘void search8(BYTE**, BYTE, BYTE, BYTE*, BYTE*, BYTE*, long unsigned int, long unsigned int*, long unsigned int*, long unsigned int*, long unsigned int*, long unsigned int, long unsigned int, long unsigned int*)’:
search8.cc:858:67: warning: overflow in implicit constant conversion [-Woverflow]
                     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff);
                                                                   ^
search16.cc: In function ‘void search16(WORD**, WORD, WORD, WORD*, WORD*, WORD*, long unsigned int, long unsigned int*, long unsigned int*, long unsigned int*, long unsigned int*, long unsigned int, long unsigned int, long unsigned int*)’:
search16.cc:573:49: warning: overflow in implicit constant conversion [-Woverflow]
   T0 = _mm_set_epi16(0, 0, 0, 0, 0, 0, 0, 0xffff);
                                                 ^

Hum, these warnings could be false-positives. And I am not sure which ISO C++ version swarm's code follows.

torognes commented 7 years ago

I have made changes to the source code to remove the warnings you have indicated. They do not represent errors or bugs. I have also added the -Wextra and -Woverflow to the compiler flags in the Makefile. Adding -Wpedantic or even -Weverything gives me many more warnings. I have looked through them, but they are all warnings that do not, as far as I can see, represent errors or bugs in the code. But it would take a lot of time to remove those warnings.

torognes commented 7 years ago

I have added the -Wpedantic warning option as well, but using the -Wno-c++11-long-long option I disabled some warnings I got in the CityHash code.