diff --git a/opm/core/wells/WellsGroup.cpp b/opm/core/wells/WellsGroup.cpp index d407c0335..e1bed0cb0 100644 --- a/opm/core/wells/WellsGroup.cpp +++ b/opm/core/wells/WellsGroup.cpp @@ -761,16 +761,28 @@ namespace Opm wells_->ctrls[self_index_]->current = ~ wells_->ctrls[self_index_]->current; } } - + +// macro to insert const_cast to get a round bug in GCC 4.6.3 where it +// suddenly believes that "this" is a const pointer, although we are not +// in a const method. +#if ( __GNUC__ == 4 ) && ( __GNUC_MINOR__ == 6 ) && ( __GNUC_PATCHLEVEL__ == 3 ) +#define CONST_CAST(T,v) const_cast(v) +#else +#define CONST_CAST(T,v) v +#endif + std::pair WellNode::getWorstOffending(const std::vector& well_reservoirrates_phase, const std::vector& well_surfacerates_phase, ProductionSpecification::ControlMode mode) { const int np = phaseUsage().num_phases; const int index = self_index_*np; - return std::make_pair(this, rateByMode(&well_reservoirrates_phase[index], - &well_surfacerates_phase[index], - mode)); + // note: CONST_CAST is just to work around a bug in GCC 4.6.3; it + // is not really needed, and should be a harmless no-op. + return std::make_pair(CONST_CAST(WellNode*,this), + rateByMode(&well_reservoirrates_phase[index], + &well_surfacerates_phase[index], + mode)); } void WellNode::applyInjGroupControl(const InjectionSpecification::ControlMode control_mode,