LCOV/GCOV branch coverage with C++ producing branches all over the place

前端 未结 6 987
清歌不尽
清歌不尽 2020-12-05 01:13

We are using LCOV/GCOV to produce test coverage of our projects. Recently we tried to enable branch-coverage additionally. But it looks like, this just doesn\'t yield the re

6条回答
  •  情歌与酒
    2020-12-05 01:36

    You can try g++ -O3 --coverage main.cpp -o testcov. I have tried this with g++-5.4 on your file and it works fine, meaning exceptions are discarded with standard printf and string calls.

    In fact, any optimization flag other than O0 will cause gcov to ignore exceptions generated for plain standard library calls in a CPP file. I am not sure if normal exceptions will also be optimized away (I don't think so, but haven't tried it yet).

    But, I am not sure if you have any requirement in your project that only O0 should be used with your code and not O1, O2, O3 or even Os.

提交回复
热议问题