LCOV - code coverage report
Current view: top level - src/test - compilerbug_tests.cpp (source / functions) Coverage Total Hit
Test: test_bitcoin_coverage.info Lines: 100.0 % 17 17
Test Date: 2024-08-28 04:44:32 Functions: 100.0 % 5 5
Branches: 55.0 % 60 33

             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                 :          10 : void __attribute__ ((noinline)) set_one(unsigned char* ptr)
      12                 :             : {
      13                 :          10 :     *ptr = 1;
      14                 :          10 : }
      15                 :             : 
      16                 :           5 : int __attribute__ ((noinline)) check_zero(unsigned char const* in, unsigned int len)
      17                 :             : {
      18         [ +  + ]:          15 :     for (unsigned int i = 0; i < len; ++i) {
      19         [ +  - ]:          10 :         if (in[i] != 0) return 0;
      20                 :             :     }
      21                 :             :     return 1;
      22                 :             : }
      23                 :             : 
      24                 :          10 : void set_one_on_stack() {
      25                 :          10 :     unsigned char buf[1];
      26                 :          10 :     set_one(buf);
      27                 :          10 : }
      28                 :             : 
      29   [ +  -  +  -  :           7 : BOOST_AUTO_TEST_CASE(gccbug_90348) {
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  +  
                      - ]
      30                 :             :     // Test for GCC bug 90348. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90348
      31         [ +  + ]:           6 :     for (int i = 0; i <= 4; ++i) {
      32                 :             :         unsigned char in[4];
      33         [ +  + ]:          15 :         for (int j = 0; j < i; ++j) {
      34                 :          10 :             in[j] = 0;
      35                 :          10 :             set_one_on_stack(); // Apparently modifies in[0]
      36                 :             :         }
      37         [ +  - ]:          10 :         BOOST_CHECK(check_zero(in, i));
      38                 :             :     }
      39                 :           1 : }
      40                 :             : #endif
      41                 :             : 
      42                 :             : BOOST_AUTO_TEST_SUITE_END()
        

Generated by: LCOV version 2.0-1