-
Notifications
You must be signed in to change notification settings - Fork 12
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
code cleanup for building with latest tools #421
Conversation
Instead of the addition on line 653 of BathyOcensEyes.cpp, can we modify the lines above it with the following (notice the minus one in the kd_range_index check):
|
Also, do we need the memset on line 459 of H5Coro.cpp that was added? |
Updated BathyOcensEyes.cpp as requested. [ 1%] Building CXX object CMakeFiles/slideruleLib.dir/packages/h5/H5Coro.cpp.o I have two choices. Keep the memset and initialize the variable or disable cppcheck-suppress uninitvar I suspect that cppchecker gets confused in |
I've been trying to move away from memsets when possible (though I am sure there are still a ton in the code). The reason is that it precludes any meaningful check of uninitialized access that would be caught by the address sanitizer in the self test. As for the alignment of |
memset has been removed info.data is being newed with C++ 17 overloaded new operator which allows for alignment. This method is preferred from st::aligned_alloc() Notice how operator delete[] also has to specify alignment or address sanitizer blows up if regular delete[] is called. x86 and ARM both support misaligned access. There is a small performance hit for both architectures since loading unaligned address to the register may require multiple fetch data instructions. ARM seems to be better at it than x86. There is also the data cache performance hit. Unaligned data may span multiple cache lines. |
H5Coro.cpp has an issue with info.data which is uint8_t*
It gets allocation as byte array but later the pointer gets casted to float/double etc. This is not safe. Starting in C++ 17 'new' on byte array may be aligned to 2, 4, 8, 16 bytes. Before C++ 17 it was either 4 or 8 bytes. cpp-check is very unhappy about it. For now, I added this line to project-config.cmake to disable the warning:
"--suppress=invalidPointerCast:/H5Coro.cpp" # info.data (uint8_t being cast to float/double ptrs. Alignment issues)
We could ignore it (what we do now)
Allocate memory with with std::aligned_alloc() guaranteeing the max needed alignment.
BathyOcensEyes.cpp line 653. Added check for kd_range_index value being out of bounds. cpp-check detected that UNCERTAINTY_COEFF_MAP may be indexed out of bounds.