LLNL / zfp

Compressed numerical arrays that support high-speed random access
http://zfp.llnl.gov
BSD 3-Clause "New" or "Revised" License
754 stars 152 forks source link

Use explicit fallthroughs in encode.c #226

Closed r-barnes closed 1 month ago

r-barnes commented 5 months ago

Using

__attribute__((fallthrough));

allows the compiler to check for implicit fallthroughs with -Wimplicit-fallthrough, which has found many issues in the codebases I've used it on.

It would be helpful if ZFP, as a core dependency, could use explicit fallthroughs to facilitate such checking.

lindstro commented 5 months ago

Thanks for the suggestion. This might be a good idea, but it would have to be done portably. I believe this attribute (and -Wimplicit-fallthrough) is not supported prior to gcc 7, and presumably there are compilers other than MSVC that don't recognize it. In C++17, it's [[fallthrough]]. I would prefer some macro mechanism that can be applied to both C and C++ code. Maybe add a fallthrough_ macro to include/zfp/internal/zfp/system.h?

lindstro commented 4 months ago

@r-barnes Take a look at 6814a4e and see if it meets your needs.

r-barnes commented 1 month ago

@lindstro - That looks good, thanks!