Project

General

Profile

Support #16108

Support #16096: Fix problems found when attempting to build with gcc 6.3.0

problem compiling lardata/Utilities/StatCollector.h with gcc 6.3.0

Added by Lynn Garren over 3 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Category:
Library
Target version:
-
Start date:
04/05/2017
Due date:
% Done:

100%

Estimated time:
Spent time:
Experiment:
LArSoft
Co-Assignees:
Duration:

Description

This block of code in lardata/Utilities/StatCollector.h fails to compile with gcc 6.3.0

template <typename T, typename W>
typename lar::util::StatCollector<T, W>::Weight_t
  lar::util::StatCollector<T, W>::Variance() const
{
  if (Weights() == Weight_t(0))
    throw std::range_error("StatCollector<>::Variance(): divide by 0");
  return std::max(Weight_t(0), (SumSq() - sqr(Sum()) / Weights()) / Weights());
} // StatCollector<T, W>::Variance()

The first part of the error message:

[ 63%] Building CXX object lardata/test/Utilities/CMakeFiles/StatCollector_test.dir/StatCollector_test.cc.o
In file included from /home/garren/scratch/larsoft/dev/srcs/lardata/test/Utilities/StatCollector_test.cc:41:0:
/home/garren/scratch/larsoft/dev/srcs/lardata/lardata/Utilities/StatCollector.h: In instantiation of
 ‘lar::util::StatCollector<T, W>::Weight_t lar::util::StatCollector<T, W>::Variance() const [with T 
= int; W = int; lar::util::StatCollector<T, W>::Weight_t = int]’:
/home/garren/scratch/larsoft/dev/srcs/lardata/test/Utilities/StatCollector_test.cc:73:5:   required 
from ‘void CheckStats(const lar::util::StatCollector<T, W>&, int, W, W, W, W) [with T = int; W = int]’
/home/garren/scratch/larsoft/dev/srcs/lardata/test/Utilities/StatCollector_test.cc:200:31:   required from ‘void StatCollectorTest() [with T = int; W = int]’
/home/garren/scratch/larsoft/dev/srcs/lardata/test/Utilities/StatCollector_test.cc:545:31:   required from here
/home/garren/scratch/larsoft/dev/srcs/lardata/lardata/Utilities/StatCollector.h:919:46: error: passing ‘const lar::util::StatCollector<int, int>’ as ‘this’ argument discards qualifiers [-fpermissive]
   return std::max(Weight_t(0), (SumSq() - sqr(Sum()) / Weights()) / Weights());
                                           ~~~^~~~~~~
/home/garren/scratch/larsoft/dev/srcs/lardata/lardata/Utilities/StatCollector.h:74:28: note:   in call to ‘constexpr V lar::util::details::WeightTracker<W>::sqr(const V&) [with V = int; W = int]’
         inline constexpr V sqr(V const& v) { return v*v; }
                            ^~~

Associated revisions

Revision 2cf286cc (diff)
Added by Gianluca Petrillo over 3 years ago

Made static a method that should have been.

This solves issue #16108 .

Revision 6fbc073b (diff)
Added by Gianluca Petrillo over 3 years ago

Made static a method that should have been.

This solves issue #16108 .

History

#1 Updated by Gianluca Petrillo over 3 years ago

  • Category set to Library
  • Status changed from Assigned to Resolved
  • % Done changed from 0 to 100

A method should have been static, but it was not.
Solved with commit lardata:2cf286cc228aa1d2fee982924b4dee7520f2a8d4 .

#2 Updated by Lynn Garren over 3 years ago

  • Status changed from Resolved to Closed


Also available in: Atom PDF