Problem¶
A project that previously compiled without error fails when
instrumented with Coco. The project used the compiler flag -Werror
(for gcc
), /WX
(for Visual C++), -warnaserror
(for C#), or
another flag that turns compiler warnings into errors
Explanation¶
When Coco instruments a program, it inserts statements into the source code that some compilers consider as dubious. When warnings are turned into errors, the compilation therefore fails.
This is so because it would be very difficult to write code that never caused compiler warnings: The set of "dubious constructs" differs between compilers and often even between compiler versions. Writing warning-free instrumentation code would be an enormous effort that better could be spent for other work.
On the other hand, compiler warnings are no sign that the code is necessarily wrong. They mostly are raised if a language construct is only error-prone and needs extra attention by the programmer.
The code that is inserted by Coco during the instrumentation is intensively tested, therefore such warnings are not necessary.
Summary¶
Turn warnings into errors during development (if you like it), but for code coverage, switch them off.