qiskit-aer icon indicating copy to clipboard operation
qiskit-aer copied to clipboard

Fix all compiler warnings and enable -Werror

Open jakelishman opened this issue 2 years ago • 0 comments

Summary

This fixes all warnings that are currently enabled in our CMake configuration, and then turns warnings into errors (if not on Windows).

The most dangerous behaviour fixed here was likely in some loop variables that were started uninitialised, then used directly as indexes into arrays. If we were unlucky, this could have been clobbering random data, and if we were a little luckier, we'd have had some segfaults.

Details and comments

There are several more categories of warnings that we may want to also suppress, mostly contained within -Wextra on clang and gcc. A lot of these are sign-compare and unused-parameter though, which will require rather more fiddling through every part of the codebase, but will make us a bit more resilient overall.

There are a few separate commits in this PR, which explain what they were doing individually.

jakelishman avatar Jan 10 '22 19:01 jakelishman