Ticket #9899: 0002-random-fix-GCC-4.7-Wuninitialized.patch

File 0002-random-fix-GCC-4.7-Wuninitialized.patch, 1.2 KB (added by mstahl@…, 9 years ago)
  • include/boost/random/binomial_distribution.hpp

    From fbd2bf08de13d7a8d27b9b074b6d16ea01357206 Mon Sep 17 00:00:00 2001
    From: Tor Lillqvist <tml@iki.fi>
    Date: Mon, 14 Apr 2014 12:33:14 +0200
    Subject: [PATCH 2/2] random: fix GCC 4.7 -Wuninitialized
    
    For some reason, GCC 4.7 targeting X86 in the Android NDK 8e complained about
    the fields in the "btrd" struct in the union in binomial_distribution
    (boost/random/binomial_distribution.hpp) maybe being uninitialized in a call
    to its copy constructor. So make sure these fields are initialized in all
    cases.
    
    Signed-off-by: Michael Stahl <mstahl@redhat.com>
    ---
     include/boost/random/binomial_distribution.hpp | 1 +
     1 file changed, 1 insertion(+)
    
    diff --git a/include/boost/random/binomial_distribution.hpp b/include/boost/random/binomial_distribution.hpp
    index 8612eca..afebe41 100644
    a b private:  
    278278        m = static_cast<IntType>((t_lcl+1)*p_lcl);
    279279
    280280        if(use_inversion()) {
     281            btrd.r = btrd.nr = btrd.npq = btrd.b = btrd.a = btrd.c = btrd.alpha = btrd.v_r = btrd.u_rv_r = 0;
    281282            q_n = pow((1 - p_lcl), static_cast<RealType>(t_lcl));
    282283        } else {
    283284            btrd.r = p_lcl/(1-p_lcl);