LCOV - code coverage report
Current view: top level - src/test - compilerbug_tests.cpp (source / functions) Hit Total Coverage
Test: coverage.lcov Lines: 23 23 100.0 %
Date: 2022-04-21 14:51:19 Functions: 4 4 100.0 %
Legend: Modified by patch:
Lines: hit not hit | Branches: + taken - not taken # not executed

Not modified by patch:
Lines: hit not hit | Branches: + taken - not taken # not executed
Branches: 7 8 87.5 %

           Branch data     Line data    Source code
#       1                 :            : // Copyright (c) 2019-2021 The Bitcoin Core developers
#       2                 :            : // Distributed under the MIT software license, see the accompanying
#       3                 :            : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
#       4                 :            : 
#       5                 :            : #include <boost/test/unit_test.hpp>
#       6                 :            : 
#       7                 :            : BOOST_AUTO_TEST_SUITE(compilerbug_tests)
#       8                 :            : 
#       9                 :            : #if defined(__GNUC__)
#      10                 :            : // This block will also be built under clang, which is fine (as it supports noinline)
#      11                 :            : void __attribute__ ((noinline)) set_one(unsigned char* ptr)
#      12                 :         20 : {
#      13                 :         20 :     *ptr = 1;
#      14                 :         20 : }
#      15                 :            : 
#      16                 :            : int __attribute__ ((noinline)) check_zero(unsigned char const* in, unsigned int len)
#      17                 :         10 : {
#      18         [ +  + ]:         30 :     for (unsigned int i = 0; i < len; ++i) {
#      19         [ -  + ]:         20 :         if (in[i] != 0) return 0;
#      20                 :         20 :     }
#      21                 :         10 :     return 1;
#      22                 :         10 : }
#      23                 :            : 
#      24                 :         20 : void set_one_on_stack() {
#      25                 :         20 :     unsigned char buf[1];
#      26                 :         20 :     set_one(buf);
#      27                 :         20 : }
#      28                 :            : 
#      29                 :          2 : BOOST_AUTO_TEST_CASE(gccbug_90348) {
#      30                 :            :     // Test for GCC bug 90348. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90348
#      31         [ +  + ]:         12 :     for (int i = 0; i <= 4; ++i) {
#      32                 :         10 :         unsigned char in[4];
#      33         [ +  + ]:         30 :         for (int j = 0; j < i; ++j) {
#      34                 :         20 :             in[j] = 0;
#      35                 :         20 :             set_one_on_stack(); // Apparently modifies in[0]
#      36                 :         20 :         }
#      37                 :         10 :         BOOST_CHECK(check_zero(in, i));
#      38                 :         10 :     }
#      39                 :          2 : }
#      40                 :            : #endif
#      41                 :            : 
#      42                 :            : BOOST_AUTO_TEST_SUITE_END()

Generated by: LCOV version 0-eol-96201-ge66f56f4af6a