seacode / gmacs

A generic size-structured stock assessment model
https://seacode.github.io/gmacs
18 stars 14 forks source link

warning when compiling tail compression #142

Closed quantifish closed 9 years ago

quantifish commented 9 years ago

I get the following warning when compiling gmacs. Nothing bad but would be better to code this away.

*** Compile: lib/tailcompression.cpp
g++ -c -g -I. -I"/home/darcy/admb/build/dist/include" -I"/home/darcy/admb/build/dist/contrib/include" -olib/tailcompression.obj lib/tailcompression.cpp
lib/tailcompression.cpp: In member function ‘void acl::negativeLogLikelihood::tail_compression()’:
lib/tailcompression.cpp:39:39: warning: converting to non-pointer type ‘long int’ from NULL [-Wconversion-null]
 cumsum(j) <= pmin ? m_jmin(i)++ : NULL;
                                   ^
lib/tailcompression.cpp:40:54: warning: converting to non-pointer type ‘long int’ from NULL [-Wconversion-null]
 j != c2 ? 1.0 - cumsum(j) < pmin ? m_jmax(i)-- : NULL : NULL;
quantifish commented 9 years ago

I fixed this by removing the ternary operators in the function and replacing with if statements. I don't have anything against ternary operators (I really like them), but they are essentially if else statements that require the else. In this case there was nothing else to do after the if, so a NULL was popped in that spot. This results in nothing happening and all is fine in the code. However, my compiler kicks up a stink because the NULL is not being assigned to anything.