Compiler error in SimDynamics: warnings being treated as errors
Hey there!
I am working on branch Ubuntu18.04 due to my recent dist upgrade. I cannot seem to compile the code, due to warnings being treated as errors. In the main CMakeLists.txt, I found
#flags
add_compile_options(-Wall)
add_compile_options(-Wextra)
add_compile_options(-Wpedantic)
#turn warnings about dangerous stuff into errors
add_compile_options(-Werror)
I had to comment the last one in order to compile anything related to SimDynamics. I guess it's not ideal, but there's no other way of compiling. I also guess that the warnings that I get may be useful for bugfixing, so there you go:
/home/fbottarel/robot-code/simox/SimDynamics/DynamicsEngine/BulletEngine/BulletOpenGL/stb_image.cpp: In function ‘unsigned char* stbi_load_main(stbi*, int*, int*, int*, int)’:
/home/fbottarel/robot-code/simox/SimDynamics/DynamicsEngine/BulletEngine/BulletOpenGL/stb_image.cpp:4795:40: warning: ‘raw_data[3]’ may be used uninitialized in this function [-Wmaybe-uninitialized]
tga_data[i * req_comp + 3] = trans_data[3];
~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
/home/fbottarel/robot-code/simox/SimDynamics/DynamicsEngine/BulletEngine/BulletOpenGL/stb_image.cpp:4592:15: note: ‘raw_data[3]’ was declared here
unsigned char raw_data[4];
^~~~~~~~
/home/fbottarel/robot-code/simox/SimDynamics/DynamicsEngine/BulletEngine/BulletOpenGL/stb_image.cpp:4774:51: warning: ‘raw_data[2]’ may be used uninitialized in this function [-Wmaybe-uninitialized]
tga_data[i * req_comp + 0] = compute_y(trans_data[0], trans_data[1], trans_data[2]);
~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/fbottarel/robot-code/simox/SimDynamics/DynamicsEngine/BulletEngine/BulletOpenGL/stb_image.cpp:4592:15: note: ‘raw_data[2]’ was declared here
unsigned char raw_data[4];
^~~~~~~~
/home/fbottarel/robot-code/simox/SimDynamics/DynamicsEngine/BulletEngine/BulletOpenGL/stb_image.cpp:4774:51: warning: ‘raw_data[1]’ may be used uninitialized in this function [-Wmaybe-uninitialized]
tga_data[i * req_comp + 0] = compute_y(trans_data[0], trans_data[1], trans_data[2]);
~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/fbottarel/robot-code/simox/SimDynamics/DynamicsEngine/BulletEngine/BulletOpenGL/stb_image.cpp:4592:15: note: ‘raw_data[1]’ was declared here
unsigned char raw_data[4];
^~~~~~~~
/home/fbottarel/robot-code/simox/VirtualRobot/Compression/CompressionBZip2.cpp: In static member function ‘static void VirtualRobot::CompressionBZip2::sendMTFValues(VirtualRobot::CompressionBZip2::EState*)’:
/home/fbottarel/robot-code/simox/VirtualRobot/Compression/CompressionBZip2.cpp:926:37: warning: ‘cost[5]’ may be used uninitialized in this function [-Wmaybe-uninitialized]
cost[t] += s->len[t][icv];
~~~~~~~~^~~~~~~~~~~~~~~~~
/home/fbottarel/robot-code/simox/VirtualRobot/Compression/CompressionBZip2.cpp:926:37: warning: ‘cost[4]’ may be used uninitialized in this function [-Wmaybe-uninitialized]
/home/fbottarel/robot-code/simox/VirtualRobot/Compression/CompressionBZip2.cpp:926:37: warning: ‘cost[3]’ may be used uninitialized in this function [-Wmaybe-uninitialized]
/home/fbottarel/robot-code/simox/VirtualRobot/Compression/CompressionBZip2.cpp:939:31: warning: ‘cost[2]’ may be used uninitialized in this function [-Wmaybe-uninitialized]
if (cost[t] < bc)
~~~~~~^