sahrk / DGGRID

A command-line application that generates and manipulates icosahedral discrete global grids.
GNU Affero General Public License v3.0
78 stars 26 forks source link

Fix fallthru in DgProjGnomonicRF #43

Closed r-barnes closed 2 years ago

r-barnes commented 3 years ago

Fixes:

/home/rick/projects/dggridR/src/src/DgProjGnomonicRF.cpp:104:14: warning: this statement may fall through [-Wimplicit-fallthrough=]
  104 |       coslam = - coslam;
      |       ~~~~~~~^~~~~~~~~~
r-barnes commented 3 years ago

I think adding a break here looks like the correct fix. If not, we should add a comment indicating that the fall-thru is expected or copy the code to eliminate the fall-thru.

sahrk commented 2 years ago

The fall through is intentional. I would prefer using a comment to indicate that, to keep it as efficient as possible.

r-barnes commented 2 years ago

@sahrk Do you have preferred C++ standard for building DGGRID in? If we use C++17 then there is a [[fallthrough]]; statement which will suppress this warning.

Otherwise in C++11 and C++14 we can use [[gnu::fallthrough]]; and __attribute__((fallthrough)) or __attribute__((__fallthrough__)) for clang.

sahrk commented 2 years ago

I'm going to have to think about this one. I hate to require C++17 for this one case, but I'm also not a fan of adding compiler-specific code just to suppress a compiler warning.

r-barnes commented 2 years ago

Okay, thanks, @sahrk

sahrk commented 2 years ago

@r-barnes I've created a FALLTHROUGH macro to handle this and pushed the fix to master. I'll leave this open for now in case you find any problem with it.