Changeset 3103


Ignore:
Timestamp:
Nov 2, 2013, 3:21:04 AM (8 years ago)
Author:
Peter
Message:

avoid compiler warning (-Wall) with gcc 4.8

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/Suite.h

    r2960 r3103  
    323323  bool run_as_root(void);
    324324
     325  // function that can be used to avoid warning: '-Wunused-but-set-variable'
     326  template<typename T>
     327  void dummie_function(T) {}
     328
    325329  template<class T>
    326330  bool Suite::test_stream(const T& t) const
     
    466470    size_t cols = c.columns();
    467471    size_t rows = c.rows();
    468     cols = rows; // just to avoid compiler warning
     472    // just to avoid compiler warning
     473    dummie_function(cols);
     474    dummie_function(rows);
    469475    const_reference x = c(0,0);
    470476    value_type y;
    471477    y = x;
     478    dummie_function(y);
    472479  }
    473480
  • trunk/test/data_lookup_1d.cc

    r2919 r3103  
    4949
    5050  suite.err() << "Testing Lookup Classes" << std::endl;
    51   bool ok = true;
    52 
    5351  suite.err() << "Testing DataLookup1D" << std::endl;
    5452  utility::Matrix gsl_m1(matrix(5));
     
    6967  if (v1.size()!=m1.columns() || v1(0)!=m1(1,0) ||
    7068      v1(1)!=m1(1,1) ) {
    71     ok =false;
     69    suite.add(false);
    7270    suite.err() << "\nERROR" << std::endl;
    7371    suite.err() << "size: " << v1.size() << " expected " << m1.columns() << "\n"
     
    8381  classifier::DataLookup1D v2(m1,1,false);
    8482  if (v2.size()!=m1.rows() || v2(0)!=m1(0,1) || v2(1)!=m1(1,1) ) {
    85     ok =false;
     83    suite.add(false);
    8684    suite.err() << "\nERROR\n"
    8785           << "size: " << v2.size() << " expected " << m1.rows() << "\n"
     
    9694  classifier::DataLookup1D v3(v2);
    9795  if (v3.size()!=v2.size() || v3(0)!=v2(0) || v3(1)!=v2(1) ) {
    98     ok =false;
     96    suite.add(false);
    9997    suite.err() << "\nERROR\n"
    10098           << "size: " << v3.size() << " expected " << v2.size() << "\n"
     
    109107  classifier::DataLookup1D v4(12,3);
    110108  if (v4.size()!=12 || v4(10)!=3 ) {
    111     ok =false;
     109    suite.add(false);
    112110    suite.err() << "\nERROR\n"
    113111           << "size: " << v4.size() << " expected " << 12 << "\n"
     
    130128  if (v5.size()!=v1.size() || v5(0)!=v1(0) || v5(1)!=v1(1) ||
    131129      v5(2)!=v1(2)) {
    132     ok=false;
     130    suite.add(false);
    133131    suite.err() << "\nERROR\n" << std::endl;
    134132  }
     
    147145  is.close();
    148146  if (v7.size()!=v6.size() || !std::isnan(v7(1))) {
    149     ok=false;
     147    suite.add(false);
    150148    suite.err() << "\nERROR\n"
    151149           << "size: " << v7.size() << " expected " << v6.size() << "\n"
     
    160158  classifier::convert(dl, v8);
    161159  if (!v5.equal(v8,0.0)) {
    162     ok = false;
     160    suite.add(false);
    163161    suite.err() << "Error: Creating a DataLookup1D(utility::vector)\n"
    164162           << "and classifier::convert(DataLookup, utility::vector)\n"
  • trunk/test/data_weight_proxy.cc

    r2919 r3103  
    121121    x = proxy.weight();
    122122    proxy.data() = proxy.weight() = 0.0;
     123    test::dummie_function(x);
    123124  }
    124125
  • trunk/test/regression.cc

    r2881 r3103  
    122122  linear_w.fit(x,y,w);
    123123  double y_predicted = linear_w.predict(1990);
    124   double y_predicted_err = linear_w.prediction_error2(1990);
    125124  if (!suite.equal(y_predicted,12.8) ){
    126125    suite.err() << "error: cannot reproduce fit." << std::endl;
    127126    suite.err() << "predicted value: " << y_predicted << " expected 12.8"
    128127           << std::endl;
     128    suite.add(false);
     129  }
     130  double y_predicted_err = linear_w.prediction_error2(1990);
     131  if (!suite.equal_sqrt(y_predicted_err,1.2) ){
     132    suite.err() << "error: cannot reproduce fit." << std::endl;
     133    suite.err() << "predicted error: " << y_predicted_err << " expected 1.2\n";
    129134    suite.add(false);
    130135  }
  • trunk/test/statistics.cc

    r2919 r3103  
    8484    double x = median(boost::random_access_iterator_archetype<double>(),
    8585                      boost::random_access_iterator_archetype<double>());
     86    test::dummie_function(x);
    8687    x = median(boost::random_access_iterator_archetype<utility::DataWeight>(),
    8788               boost::random_access_iterator_archetype<utility::DataWeight>());
     89    test::dummie_function(x);
    8890  }
    8991  statistics::percentile2(data.begin(), data.end(), 100);
     
    111113    double x = average(boost::input_iterator_archetype<double>(),
    112114                       boost::input_iterator_archetype<double>());
    113     x = average(boost::input_iterator_archetype_no_proxy<utility::DataWeight>(),
    114                 boost::input_iterator_archetype_no_proxy<utility::DataWeight>());
    115            
    116   }
    117  
     115    test::dummie_function(x);
     116    using utility::DataWeight;
     117    x = average(boost::input_iterator_archetype_no_proxy<DataWeight>(),
     118                boost::input_iterator_archetype_no_proxy<DataWeight>());
     119    test::dummie_function(x);
     120  }
     121
    118122  test_mad(suite);
    119123
     
    179183    double x = mad(boost::random_access_iterator_archetype<double>(),
    180184                   boost::random_access_iterator_archetype<double>());
     185    test::dummie_function(x);
    181186    x = mad(boost::random_access_iterator_archetype<utility::DataWeight>(),
    182187            boost::random_access_iterator_archetype<utility::DataWeight>());
     188    test::dummie_function(x);
    183189  }
    184190}
     
    191197  double m = 0;
    192198  m = statistics::median(x.begin(), x.end(), true);
     199  test::dummie_function(m);
    193200}
    194201
     
    255262    typedef random_access_iterator_archetype<double> Iterator;
    256263    double x = percentiler(Iterator(), Iterator());
     264    test::dummie_function(x);
    257265    using utility::DataWeight;
    258266    typedef random_access_iterator_archetype<DataWeight> WeigtedItererator;
    259267    x = percentiler(WeigtedItererator(), WeigtedItererator());
     268    test::dummie_function(x);
    260269  }
    261270}
  • trunk/test/utility.cc

    r3098 r3103  
    293293  const std::map<std::string, int> m2(m);
    294294  int i = utility::get(m2, static_cast<std::string>("one"));
    295   i = 0; // avoid compiler warning
     295  test::dummie_function(i); // avoid compiler warning
    296296  try {
    297297    utility::get(m2, static_cast<std::string>("three"));
  • trunk/yat/utility/concept_check.h

    r2673 r3103  
    8888      size_t n = t_.rows();
    8989      n = t_.columns();
     90      some_func(n);
    9091      BOOST_CONCEPT_ASSERT((boost::RandomAccessIterator<const_iterator>));
    9192      BOOST_CONCEPT_ASSERT((boost::RandomAccessIterator<const_row_iterator>));
     
    9495
    9596  private:
     97    void some_func(size_t x) const {}
    9698    T t_;
    9799    value_type value_;
     
    279281      boost::random_access_iterator_archetype<double> unweighted;
    280282      boost::random_access_iterator_archetype<DataWeight> weighted;
    281       double d;
    282       d = distance_(unweighted, unweighted, unweighted);
    283       d = distance_(unweighted, unweighted, weighted);
    284       d = distance_(weighted, weighted, unweighted);
    285       d = distance_(weighted, weighted, weighted);
    286     }
    287   private:
     283      double d=0;
     284      d += distance_(unweighted, unweighted, unweighted);
     285      d += distance_(unweighted, unweighted, weighted);
     286      d += distance_(weighted, weighted, unweighted);
     287      d += distance_(weighted, weighted, weighted);
     288      // avoid compiler warning
     289      func(d);
     290    }
     291  private:
     292    void func(double x) {}
    288293    T distance_;
    289294  };
Note: See TracChangeset for help on using the changeset viewer.