From 3ab5b5b8e2c7add2986f8c32ad1a1d595030da3d Mon Sep 17 00:00:00 2001
From: Gabriel Studer <gabriel.studer@unibas.ch>
Date: Sat, 30 Dec 2017 16:56:25 +0100
Subject: [PATCH] make it compile with gcc 7.2

solves a variety of problems that gcc (mainly the c++11 as default)
throws at us.
---
 modules/base/src/test_utils/compare_files.cc  |  4 +--
 modules/config/base.hh                        | 34 ++++++++++++-------
 modules/gfx/src/impl/cartoon_renderer.cc      |  2 +-
 modules/gfx/src/scene.cc                      |  2 +-
 modules/gfx/src/texture.hh                    |  2 +-
 modules/gfx/src/vertex_array.cc               |  2 +-
 modules/gui/src/data_viewer/data_viewer.hh    |  5 +++
 .../src/data_viewer/data_viewer_panel_base.hh |  6 ++--
 .../gui/src/data_viewer/drawing_functions.cc  | 12 +++----
 modules/gui/src/data_viewer/fft_panel.hh      |  4 +++
 modules/gui/src/file_type_dialog.hh           |  4 ++-
 modules/img/alg/src/polar.cc                  |  6 ++--
 modules/img/base/src/base.hh                  | 10 ------
 modules/img/base/src/image_handle.cc          |  2 +-
 modules/img/base/src/image_list.cc            |  4 +--
 modules/img/base/src/point.hh                 | 16 ++++-----
 .../img/base/src/raster_image/raster_image.cc |  4 +--
 modules/info/src/info_handle.cc               |  2 +-
 modules/info/src/item_type_cast.hh            |  2 +-
 modules/io/src/formatted_line.hh              |  2 +-
 modules/io/src/img/map_io_tiff_handler.cc     |  4 +--
 modules/io/tests/test_io_mmcif.py             |  2 +-
 modules/io/tests/test_mmcif_reader.cc         |  3 +-
 modules/mol/alg/src/entity_to_density.cc      |  6 ++--
 modules/mol/alg/src/filter_clashes.cc         | 18 +++++-----
 modules/mol/base/src/bond_handle.cc           |  2 +-
 modules/mol/base/src/impl/atom_impl.cc        |  2 +-
 modules/mol/base/src/spatial_organizer.hh     |  6 ++--
 modules/mol/base/src/surface_handle.hh        |  2 +-
 modules/mol/mm/src/modeller.cc                |  6 ++--
 30 files changed, 95 insertions(+), 81 deletions(-)

diff --git a/modules/base/src/test_utils/compare_files.cc b/modules/base/src/test_utils/compare_files.cc
index 904b14a7f..83a52f66f 100644
--- a/modules/base/src/test_utils/compare_files.cc
+++ b/modules/base/src/test_utils/compare_files.cc
@@ -37,8 +37,8 @@ bool compare_files(const String& test, const String& gold_standard)
   }
   String test_line, gold_line;
   while (true) {
-    bool test_end=std::getline(test_stream, test_line) != 0;
-    bool gold_end=std::getline(gold_stream, gold_line) != 0;
+    bool test_end= !std::getline(test_stream, test_line);
+    bool gold_end= !std::getline(gold_stream, gold_line);
     if (!(test_end || gold_end)) {
       return true;
     }
diff --git a/modules/config/base.hh b/modules/config/base.hh
index 2019437b5..ade55f5fc 100644
--- a/modules/config/base.hh
+++ b/modules/config/base.hh
@@ -51,28 +51,40 @@ typedef unsigned int uint;
 typedef std::complex<Real> Complex;
 typedef unsigned short Word;
 
+typedef std::string String;
 
-
-#ifndef round_function
-#define round_function
-#ifndef round
-inline Real round( Real d )
+#ifndef round_real_function
+#define round_real_function
+#ifndef round_real
+inline Real round_real(Real d) 
 {
   return floor(d+Real(0.5));
 }
 #endif
 #endif
 
-#ifndef rint_function
-#define rint_function
-#ifndef rint
-inline Real rint(Real d)
+#ifndef round_float_function
+#define round_float_function
+#ifndef round_float
+inline float round_float(float d) 
 {
-  return floor(d+Real(0.5));
+  return (float)floor(d+float(0.5));
+}
+#endif
+#endif
+
+#ifndef round_double_function
+#define round_double_function
+#ifndef round_double
+inline double round_double(double d) 
+{
+  return (double)floor(d+double(0.5));
 }
 #endif
 #endif
 
+
+
 #if _MSC_VER
 #pragma warning(disable:4251)
 #pragma warning(disable:4275)
@@ -104,7 +116,5 @@ inline double log2( double n )
 #endif
 
 
-typedef std::string String;
-
 
 #endif
diff --git a/modules/gfx/src/impl/cartoon_renderer.cc b/modules/gfx/src/impl/cartoon_renderer.cc
index 00894483d..060668cce 100644
--- a/modules/gfx/src/impl/cartoon_renderer.cc
+++ b/modules/gfx/src/impl/cartoon_renderer.cc
@@ -380,7 +380,7 @@ void CartoonRenderer::rebuild_spline_obj(IndexedVertexArray& va,
         double ang=-geom::SignedAngle(geom::Cross(slist.at(sc-1).normal,dir),
                                       geom::Cross(slist.at(sc).normal,dir),
                                       dir);
-        offset=psize+static_cast<size_t>(round(ang*of)+psized);
+        offset=psize+static_cast<size_t>(round_real(ang*of)+psized);
       }
       if(slist.at(sc).type==3) {
         if(slist.at(sc-1).type!=3) {
diff --git a/modules/gfx/src/scene.cc b/modules/gfx/src/scene.cc
index 5c1e9cbb7..98b47c9cb 100644
--- a/modules/gfx/src/scene.cc
+++ b/modules/gfx/src/scene.cc
@@ -1097,7 +1097,7 @@ bool Scene::HasNode(const String& name) const
 {
   FindNode fn(name);
   this->Apply(fn);
-  return fn.node;
+  return static_cast<bool>(fn.node);
 }
 
 void Scene::Apply(const InputEvent& e, bool request_redraw)
diff --git a/modules/gfx/src/texture.hh b/modules/gfx/src/texture.hh
index aa3fec45f..cf25b9d4f 100644
--- a/modules/gfx/src/texture.hh
+++ b/modules/gfx/src/texture.hh
@@ -51,7 +51,7 @@ public:
 
   Texture(const Bitmap& b);
 
-  bool IsValid() const {return d_;}
+  bool IsValid() const {return static_cast<bool>(d_);}
 
   float* data() {return &d_[0];}
   
diff --git a/modules/gfx/src/vertex_array.cc b/modules/gfx/src/vertex_array.cc
index 520e0d0e9..a1f61d40b 100644
--- a/modules/gfx/src/vertex_array.cc
+++ b/modules/gfx/src/vertex_array.cc
@@ -508,7 +508,7 @@ namespace {
   unsigned int col_to_index(float* c)
   {
     // don't look too closely - I am lacking sufficient caffeine to do this more elegantly
-    int ret= std::max(0,std::min<int>(511,static_cast<int>(round(c[0]*7.0f))*64+static_cast<int>(round(c[1]*7.0f))*8+static_cast<unsigned int>(round(c[2]*7.0f))));
+    int ret= std::max(0,std::min<int>(511,static_cast<int>(round_real(c[0]*7.0f))*64+static_cast<int>(round_real(c[1]*7.0f))*8+static_cast<unsigned int>(round_real(c[2]*7.0f))));
     return static_cast<unsigned int>(ret);
   }
 }
diff --git a/modules/gui/src/data_viewer/data_viewer.hh b/modules/gui/src/data_viewer/data_viewer.hh
index ca6893edc..c1f18847e 100644
--- a/modules/gui/src/data_viewer/data_viewer.hh
+++ b/modules/gui/src/data_viewer/data_viewer.hh
@@ -25,6 +25,8 @@
 #ifndef IMG_GUI_DATA_VIEWER_H
 #define IMG_GUI_DATA_VIEWER_H
 
+#ifndef Q_MOC_RUN
+
 #include <map>
 
 #include <ost/base.hh>
@@ -42,6 +44,9 @@
 #include "fft_panel.hh"
 #include <ost/gui/module_config.hh>
 
+#endif
+
+
 //fw decl
 class QLabel;
 
diff --git a/modules/gui/src/data_viewer/data_viewer_panel_base.hh b/modules/gui/src/data_viewer/data_viewer_panel_base.hh
index 699efd372..be3ac007e 100644
--- a/modules/gui/src/data_viewer/data_viewer_panel_base.hh
+++ b/modules/gui/src/data_viewer/data_viewer_panel_base.hh
@@ -26,10 +26,10 @@
 #define DATA_VIEWER_PANEL_BASE_HH_
 
 #include <map>    
-#include <boost/shared_ptr.hpp>
-
 
+#ifndef Q_MOC_RUN
 
+#include <boost/shared_ptr.hpp>
 #include <ost/base.hh>
 #include <ost/img/extent.hh>
 #include <ost/img/data_observer.hh>
@@ -41,6 +41,8 @@
 
 #include <ost/img/normalizer_impl.hh>
 
+#endif
+
 #include <QWidget>
 #include <QCursor>
 #include <QMenu>
diff --git a/modules/gui/src/data_viewer/drawing_functions.cc b/modules/gui/src/data_viewer/drawing_functions.cc
index f27b3eb0d..324c29af9 100644
--- a/modules/gui/src/data_viewer/drawing_functions.cc
+++ b/modules/gui/src/data_viewer/drawing_functions.cc
@@ -64,7 +64,7 @@ void DrawEllipse(QPainter& pnt, const QPoint& center, Real rx, Real ry, Real ang
     Real ang=static_cast<Real>(j)/static_cast<Real>(numpoints)*2.0*M_PI;
     Real dx=rx*cos(ang);
     Real dy=ry*sin(ang);
-    qpoly << QPoint(static_cast<int>(round(center.x()+dx*cos(-angle)+dy*sin(-angle))),static_cast<int>(round(center.y()-dx*sin(-angle)+dy*cos(-angle))));
+    qpoly << QPoint(static_cast<int>(round_real(center.x()+dx*cos(-angle)+dy*sin(-angle))),static_cast<int>(round_real(center.y()-dx*sin(-angle)+dy*cos(-angle))));
   }
   pnt.drawPolyline(qpoly);
 }
@@ -86,13 +86,13 @@ void DrawHyperbola(QPainter& pnt, const QSize& size, const geom::Vec2& center, R
       x=sqrt((y*y/ry/ry-1.0)*rx*rx);
     }
     geom::Vec2 pos=Rotate(Vec2(x,y),-angle)+center;
-    p1=QPoint(static_cast<int>(round(pos[0])),static_cast<int>(round(pos[1])));
+    p1=QPoint(static_cast<int>(round_real(pos[0])),static_cast<int>(round_real(pos[1])));
     pos=Rotate(Vec2(x,-y),-angle)+center;
-    p2=QPoint(static_cast<int>(round(pos[0])),static_cast<int>(round(pos[1])));
+    p2=QPoint(static_cast<int>(round_real(pos[0])),static_cast<int>(round_real(pos[1])));
     pos=Rotate(Vec2(-x,y),-angle)+center;
-    p3=QPoint(static_cast<int>(round(pos[0])),static_cast<int>(round(pos[1])));
+    p3=QPoint(static_cast<int>(round_real(pos[0])),static_cast<int>(round_real(pos[1])));
     pos=Rotate(Vec2(-x,-y),-angle)+center;
-    p4=QPoint(static_cast<int>(round(pos[0])),static_cast<int>(round(pos[1])));
+    p4=QPoint(static_cast<int>(round_real(pos[0])),static_cast<int>(round_real(pos[1])));
     if(orientation){
       if(flagp1){
         points1.push_back(p1);
@@ -150,7 +150,7 @@ void DrawHalfEllipse(QPainter& pnt, const QPoint& center, Real rx, Real ry, Real
     Real ang=j/static_cast<Real>(numpoints)*M_PI+M_PI;
     Real dx=rx*cos(ang);
     Real dy=ry*sin(ang);
-    qpoly << QPoint(static_cast<int>(round(center.x()+dx*cos(-angle)+dy*sin(-angle))),static_cast<int>(round(center.y()-dx*sin(-angle)+dy*cos(-angle))));
+    qpoly << QPoint(static_cast<int>(round_real(center.x()+dx*cos(-angle)+dy*sin(-angle))),static_cast<int>(round_real(center.y()-dx*sin(-angle)+dy*cos(-angle))));
   }
   pnt.drawPolyline(qpoly);
 }
diff --git a/modules/gui/src/data_viewer/fft_panel.hh b/modules/gui/src/data_viewer/fft_panel.hh
index 75a30fed8..ac0df0f56 100644
--- a/modules/gui/src/data_viewer/fft_panel.hh
+++ b/modules/gui/src/data_viewer/fft_panel.hh
@@ -24,10 +24,14 @@
   Author: Andreas Schenk
 */
 
+#ifndef Q_MOC_RUN
+
 #include <ost/gui/module_config.hh>
 #include <ost/img/data_observer.hh>
 #include "data_viewer_panel_base.hh"
 
+#endif
+
 namespace ost { namespace img { namespace gui {
 
 class ParentDataObserver: public DataObserver
diff --git a/modules/gui/src/file_type_dialog.hh b/modules/gui/src/file_type_dialog.hh
index f1fe6ce5e..270d35131 100644
--- a/modules/gui/src/file_type_dialog.hh
+++ b/modules/gui/src/file_type_dialog.hh
@@ -25,7 +25,7 @@
 
 #include <ost/gui/module_config.hh>
 
-
+#ifndef Q_MOC_RUN
 
 #include <ost/io/mol/entity_io_handler.hh>
 #include <ost/io/seq/sequence_io_handler.hh>
@@ -34,6 +34,8 @@
 #include <ost/io/img/map_io_handler.hh>
 #endif
 
+#endif
+
 #include <QDialog>
 #include <QMetaType>
 
diff --git a/modules/img/alg/src/polar.cc b/modules/img/alg/src/polar.cc
index aa5fa3745..dc77c0655 100644
--- a/modules/img/alg/src/polar.cc
+++ b/modules/img/alg/src/polar.cc
@@ -36,7 +36,7 @@ public:
   ImageStateBasePtr VisitState(const img::ImageStateImpl<T,D>& isi) {
     Size s=isi.GetExtent().GetSize();
 //    unsigned int rmax=static_cast<unsigned int>(std::min(s[0],s[1])*0.5);
-    unsigned int rmax=static_cast<unsigned int>(round(sqrt(s[0]*s[0]+s[1]*s[1])*0.5));
+    unsigned int rmax=static_cast<unsigned int>(round_real(sqrt(s[0]*s[0]+s[1]*s[1])*0.5));
     Extent e(Size(rmax,static_cast<unsigned int>(rmax*2.0*M_PI*sampling_)));
     std::cerr << e << std::endl;
     boost::shared_ptr<ImageStateImpl<T,image_state::SpatialDomain> > result(new ImageStateImpl<T,image_state::SpatialDomain>(e,isi.GetSampling()));
@@ -76,7 +76,7 @@ ImageHandle Polar::Visit(const ConstImageHandle& i)
 #else
   Size s=i.GetExtent().GetSize();
 //  unsigned int rmax=static_cast<unsigned int>(std::min(s[0],s[1])*0.5);
-  unsigned int rmax=static_cast<unsigned int>(round(sqrt(static_cast<double>(s[0]*s[0]+s[1]*s[1]))*0.5));
+  unsigned int rmax=static_cast<unsigned int>(round_double(sqrt(static_cast<double>(s[0]*s[0]+s[1]*s[1]))*0.5));
   Extent e(Size(rmax,static_cast<unsigned int>(rmax*2.0*M_PI*sampling_)));
   ImageHandle result = CreateImage(e,i.GetType(),SPATIAL);
   Real prefac=1/(rmax*sampling_);
@@ -103,7 +103,7 @@ ImageHandle EllipticPolar::Visit(const ConstImageHandle& i)
   Size s=i.GetExtent().GetSize();
   Real ang=atan(static_cast<double>(s[1]/s[0]));
   Real mdist=std::min(Length(ellipse.AtAngle(ang)),Length(ellipse.AtAngle(-ang)));
-  unsigned int rmax=static_cast<unsigned int>(round(sqrt(static_cast<double>(s[0]*s[0]+s[1]*s[1]))*0.5));
+  unsigned int rmax=static_cast<unsigned int>(round_double(sqrt(static_cast<double>(s[0]*s[0]+s[1]*s[1]))*0.5));
   Extent e(Size(rmax,static_cast<unsigned int>(rmax*2.0*M_PI*sampling_)));
   ImageHandle result = CreateImage(e,i.GetType(),SPATIAL);
   Real prefac=1/(rmax*sampling_);
diff --git a/modules/img/base/src/base.hh b/modules/img/base/src/base.hh
index 0122a0737..f5d73f5f4 100644
--- a/modules/img/base/src/base.hh
+++ b/modules/img/base/src/base.hh
@@ -44,21 +44,11 @@
 #pragma warning(disable:4231)
 #endif
 
-
 #ifdef IRIX
-inline Real round(Real x) {return rint(x);}
-inline float roundf(float x) {return (float)rint((Real)x);}
 using  std::cos;
 using  std::sin;
 #endif
 
-#ifndef round_function
-#define round_function
-#ifndef round
-inline int round(Real x) {return floor(x+0.5);}
-#endif
-#endif
-
 namespace ost { namespace img {
 
   // String is not always predefined
diff --git a/modules/img/base/src/image_handle.cc b/modules/img/base/src/image_handle.cc
index c0059be0b..fe84239cd 100644
--- a/modules/img/base/src/image_handle.cc
+++ b/modules/img/base/src/image_handle.cc
@@ -153,7 +153,7 @@ void ImageHandle::Reset(const Extent &e, DataType type,DataDomain dom)
 
 bool ImageHandle::IsValid() const
 {
-  return impl_;
+  return static_cast<bool>(impl_);
 }
 
 long ImageHandle::MemSize() const
diff --git a/modules/img/base/src/image_list.cc b/modules/img/base/src/image_list.cc
index 522e5f7af..a0f5365f1 100644
--- a/modules/img/base/src/image_list.cc
+++ b/modules/img/base/src/image_list.cc
@@ -43,9 +43,9 @@ ImageHandle ImageList::GetGallery(unsigned int columns,bool border)
       bsize=1;
     }
     if(columns==0){
-        columns=static_cast<int>(round(sqrt(static_cast<Real>(size()))));
+        columns=static_cast<int>(round_real(sqrt(static_cast<Real>(size()))));
     }
-    unsigned int rows=static_cast<int>(round(static_cast<Real>(size())/static_cast<Real>(columns)));
+    unsigned int rows=static_cast<int>(round_real(static_cast<Real>(size())/static_cast<Real>(columns)));
     Size s=get_max_size_();
     DataType datatype=get_data_type_();
     if(s[2]>1){
diff --git a/modules/img/base/src/point.hh b/modules/img/base/src/point.hh
index 0d9f307e7..079530385 100644
--- a/modules/img/base/src/point.hh
+++ b/modules/img/base/src/point.hh
@@ -87,8 +87,8 @@ public:
   
   //! conversion from Vec2
   explicit Point(const Vec2& v):
-    x(static_cast<int>(round(v[0]))),
-    y(static_cast<int>(round(v[1]))),
+    x(static_cast<int>(round_real(v[0]))),
+    y(static_cast<int>(round_real(v[1]))),
     z()
   {
   } 
@@ -96,18 +96,18 @@ public:
 
   //! conversion from Vec3
   explicit Point(const Vec3& v):
-    x(static_cast<int>(round(v[0]))),
-    y(static_cast<int>(round(v[1]))),
-    z(static_cast<int>(round(v[2])))
+    x(static_cast<int>(round_real(v[0]))),
+    y(static_cast<int>(round_real(v[1]))),
+    z(static_cast<int>(round_real(v[2])))
   {
   } 
 
 
   //! conversion from Vec4 (normalization)
   explicit Point(const Vec4& v):
-    x(static_cast<int>(round(v[0]))),
-    y(static_cast<int>(round(v[1]))),
-    z(static_cast<int>(round(v[2])))
+    x(static_cast<int>(round_real(v[0]))),
+    y(static_cast<int>(round_real(v[1]))),
+    z(static_cast<int>(round_real(v[2])))
   {
     if(std::abs(v[3])<1e-100) {
       throw geom::OutOfRangeException("4th element of Vec4 is too close to zero for normalization");
diff --git a/modules/img/base/src/raster_image/raster_image.cc b/modules/img/base/src/raster_image/raster_image.cc
index 143e1110b..febbe0314 100644
--- a/modules/img/base/src/raster_image/raster_image.cc
+++ b/modules/img/base/src/raster_image/raster_image.cc
@@ -191,7 +191,7 @@ RasterImage::Pixel get_value_t(const Data& d, const Point& p, const geom::Vec3&
       if(signcolor) vv = std::abs(vv);
       rv = n->Convert(vv);
     }
-    uchar v = (unsigned char)::round(rv);
+    uchar v = (unsigned char)::round_real(rv);
     if(signcolor) {
       float hsv[3];
       hsv[0] = sg ? 0.0 : 120.0;
@@ -268,7 +268,7 @@ RasterImage::Pixel isi_to_pixel(const ImageStateImpl<T,D>& isi,
   } else {
     rv = n->Convert(Val2Val<T,Real>(isi.Value(p)));
   }
-  uchar v = (unsigned char)::round(rv);
+  uchar v = (unsigned char)::round_real(rv);
   return RasterImage::Pixel(v,v,v);
 }
 
diff --git a/modules/info/src/info_handle.cc b/modules/info/src/info_handle.cc
index 9b6ecbc49..263ae222c 100644
--- a/modules/info/src/info_handle.cc
+++ b/modules/info/src/info_handle.cc
@@ -74,7 +74,7 @@ void InfoHandle::Export(const String& file) const
 
 bool InfoHandle::IsValid() const
 {
-  return impl_;
+  return static_cast<bool>(impl_);
 }
 
 
diff --git a/modules/info/src/item_type_cast.hh b/modules/info/src/item_type_cast.hh
index 0b364d575..89c0aedfa 100644
--- a/modules/info/src/item_type_cast.hh
+++ b/modules/info/src/item_type_cast.hh
@@ -163,7 +163,7 @@ template <> void set_new_type<IT_FLOAT,IT_STRING>(EleImpl& item)
 
 template <> void set_new_type<IT_FLOAT,IT_INT>(EleImpl& item)
 {
-  item.SetIntRepr(static_cast<int>(round(item.GetFloatRepr())));
+  item.SetIntRepr(static_cast<int>(round_real(item.GetFloatRepr())));
 }
 
 template <> void set_new_type<IT_FLOAT,IT_FLOAT>(EleImpl& item)
diff --git a/modules/io/src/formatted_line.hh b/modules/io/src/formatted_line.hh
index 444a4e4aa..40772bc18 100644
--- a/modules/io/src/formatted_line.hh
+++ b/modules/io/src/formatted_line.hh
@@ -88,7 +88,7 @@ struct LPaddedFloat {
         len = snprintf(data, sizeof(data), "%.3f", val);
         break;
       default:
-        Real rounded_val=round(val*pow(Real(10), prec))*pow(Real(0.1), prec);
+        Real rounded_val=round_real(val*pow(Real(10), prec))*pow(Real(0.1), prec);
         size_t curr=0;
         bool minus=rounded_val<0;
         rounded_val=std::abs(rounded_val);
diff --git a/modules/io/src/img/map_io_tiff_handler.cc b/modules/io/src/img/map_io_tiff_handler.cc
index cd0ad364c..b47429642 100644
--- a/modules/io/src/img/map_io_tiff_handler.cc
+++ b/modules/io/src/img/map_io_tiff_handler.cc
@@ -847,11 +847,11 @@ void MapIOTiffHandler::load_image_data(TIFF* tfile, img::ImageHandle& image,  co
     break;
   case RESUNIT_INCH:
     image.SetPixelSampling(geom::Vec3(xreso*Units::in,yreso*Units::in,1));
-    image.SetSpatialOrigin(img::Point(static_cast<int>(round(xpos/xreso)),static_cast<int>(round(ypos/yreso)),0));
+    image.SetSpatialOrigin(img::Point(static_cast<int>(round_float(xpos/xreso)),static_cast<int>(round_float(ypos/yreso)),0));
     break;
   case RESUNIT_CENTIMETER:
     image.SetPixelSampling(geom::Vec3(xreso*Units::cm,yreso*Units::cm,1));
-    image.SetSpatialOrigin(img::Point(static_cast<int>(round(xpos/xreso)),static_cast<int>(round(ypos/yreso)),0));
+    image.SetSpatialOrigin(img::Point(static_cast<int>(round_float(xpos/xreso)),static_cast<int>(round_float(ypos/yreso)),0));
     break;
   }
   _TIFFfree(buf);
diff --git a/modules/io/tests/test_io_mmcif.py b/modules/io/tests/test_io_mmcif.py
index c7cb807bc..25cadebe6 100644
--- a/modules/io/tests/test_io_mmcif.py
+++ b/modules/io/tests/test_io_mmcif.py
@@ -150,7 +150,7 @@ class TestMMCifInfo(unittest.TestCase):
                       [mol.ResNum(1), mol.ResNum(2), mol.ResNum(3), mol.ResNum(4)])
 
   def test_mmcifinfo_biounit_pdbize(self):
-    ent, seqres, info = io.LoadMMCIF("testfiles/mmcif/3T6C.cif.gz",
+    ent, seqres, info = io.LoadMMCIF("testfiles/mmcif/3T6C.cif",
                                      seqres=True,
                                      info=True)
     pdb_ent = info.GetBioUnits()[0].PDBize(ent)
diff --git a/modules/io/tests/test_mmcif_reader.cc b/modules/io/tests/test_mmcif_reader.cc
index 2cfac7fce..6c97689dc 100644
--- a/modules/io/tests/test_mmcif_reader.cc
+++ b/modules/io/tests/test_mmcif_reader.cc
@@ -1327,7 +1327,8 @@ BOOST_AUTO_TEST_CASE(mmcif_test_chain_mappings)
   BOOST_TEST_MESSAGE("  Running mmcif_test_chain_mappings tests...");
   
   // check compound lib
-  bool compound_lib_available = SetDefaultCompoundLib();
+  bool compound_lib_available = 
+  static_cast<bool>(SetDefaultCompoundLib());
 
   // load data
   mol::EntityHandle eh = mol::CreateEntity();
diff --git a/modules/mol/alg/src/entity_to_density.cc b/modules/mol/alg/src/entity_to_density.cc
index b6ac49efc..002b7ff1e 100644
--- a/modules/mol/alg/src/entity_to_density.cc
+++ b/modules/mol/alg/src/entity_to_density.cc
@@ -307,9 +307,9 @@ public:
 
             geom::Vec3 adjusted_coord  = coord-map_start;
             geom::Vec3 pixel_coord=is.CoordToIndex(coord);
-            img::Point rounded_pixel_coord(round(pixel_coord[0]),
-                                            round(pixel_coord[1]),
-                                            round(pixel_coord[2]));
+            img::Point rounded_pixel_coord(round_real(pixel_coord[0]),
+                                            round_real(pixel_coord[1]),
+                                            round_real(pixel_coord[2]));
 
             uint x_limit = ceil(2.0*four_sigma/sampling[0])+1;
             uint y_limit = ceil(2.0*four_sigma/sampling[1])+1;
diff --git a/modules/mol/alg/src/filter_clashes.cc b/modules/mol/alg/src/filter_clashes.cc
index 690a10aff..b2f9f6112 100644
--- a/modules/mol/alg/src/filter_clashes.cc
+++ b/modules/mol/alg/src/filter_clashes.cc
@@ -118,7 +118,7 @@ std::pair<Real,Real> ClashingDistances::GetClashingDistance(const String& ele1,c
   std::map <String,std::pair<Real,Real> >::const_iterator find_ci= min_distance_.find(key);
   if (find_ci == min_distance_.end()) {
       std::stringstream serr;
-      serr << "Entry for distance " << stkey <<  " not found in the parameter table";   
+      serr << "Entry for distance " << key <<  " not found in the parameter table";   
       throw Error(serr.str());
   }    
   return find_ci->second;
@@ -207,7 +207,7 @@ StereoChemicalParams FillStereoChemicalParams(const String& header, std::vector<
   bool found=false;
   std::vector<String>::const_iterator line_iter=stereo_chemical_props_file.begin();
   while (line_iter!=stereo_chemical_props_file.end()) {
-    if ((*line_iter).length() > 1) {
+    if ((*line_iter).length()!=0 && (*line_iter).length()!=1) {
       StringRef line_string_ref(line_iter->data(),(*line_iter).length());
       std::vector<StringRef> line_str_vec = line_string_ref.split();
       if (line_str_vec[0].str()==header) {
@@ -266,8 +266,8 @@ StereoChemicalParams FillStereoChemicalParams(const String& header, std::vector<
               return StereoChemicalParams();
             }            
             table.SetParam(rearranged_item,res,value,stddev);
-          }
-          line_iter++;
+            line_iter++;
+            }  
         }
       }  
     }
@@ -286,7 +286,7 @@ ClashingDistances FillClashingDistances(std::vector<String>& stereo_chemical_pro
   bool found=false;
   std::vector<String>::const_iterator line_iter=stereo_chemical_props_file.begin();
   while (line_iter!=stereo_chemical_props_file.end()) {
-    if ((*line_iter).length() > 1) {
+    if ((*line_iter).length()!=0 && (*line_iter).length()!=1) {
       StringRef line_string_ref(line_iter->data(),(*line_iter).length());
       std::vector<StringRef> line_str_vec = line_string_ref.split();
       if (line_str_vec[0].str()=="Non-bonded") {
@@ -329,11 +329,11 @@ ClashingDistances FillClashingDistances(std::vector<String>& stereo_chemical_pro
               table.SetClashingDistance(ele2,ele1,value,stddev);
             } else {
               table.SetClashingDistance(ele1,ele2,value,stddev);
-            }
-          }
-          line_iter++;
+            }  
+            line_iter++;
+          }  
         }
-      }
+      }  
     }
     line_iter++;    
   }
diff --git a/modules/mol/base/src/bond_handle.cc b/modules/mol/base/src/bond_handle.cc
index 3be1b88bd..9a68a860d 100644
--- a/modules/mol/base/src/bond_handle.cc
+++ b/modules/mol/base/src/bond_handle.cc
@@ -47,7 +47,7 @@ BondHandle::operator bool() const
 }
 
 bool BondHandle::IsValid() const {
-  return impl_;
+  return static_cast<bool>(impl_);
 }
 
 AtomHandle BondHandle::GetFirst() const
diff --git a/modules/mol/base/src/impl/atom_impl.cc b/modules/mol/base/src/impl/atom_impl.cc
index 7bc585b14..f0852b738 100644
--- a/modules/mol/base/src/impl/atom_impl.cc
+++ b/modules/mol/base/src/impl/atom_impl.cc
@@ -227,7 +227,7 @@ std::ostream& operator<<(std::ostream& o, const AtomImplPtr ap)
 }
 
 bool ConnectorExists(const AtomImplPtr& a, const AtomImplPtr& b) {
-  return GetConnector(a, b);
+  return static_cast<bool>(GetConnector(a, b));
 }
 
 ConnectorImplP GetConnector(const AtomImplPtr& a, const AtomImplPtr& b) {
diff --git a/modules/mol/base/src/spatial_organizer.hh b/modules/mol/base/src/spatial_organizer.hh
index 0e9dce740..c48c0f293 100644
--- a/modules/mol/base/src/spatial_organizer.hh
+++ b/modules/mol/base/src/spatial_organizer.hh
@@ -215,9 +215,9 @@ private:
   Index max_;
 
   Index gen_index(const VEC& pos) const {
-    Index nrvo(static_cast<int>(round(pos[0]/delta_)),
-               static_cast<int>(round(pos[1]/delta_)),
-               static_cast<int>(round(pos[2]/delta_)));
+    Index nrvo(static_cast<int>(round_real(pos[0]/delta_)),
+               static_cast<int>(round_real(pos[1]/delta_)),
+               static_cast<int>(round_real(pos[2]/delta_)));
     return nrvo;
   }
 
diff --git a/modules/mol/base/src/surface_handle.hh b/modules/mol/base/src/surface_handle.hh
index 3524375d3..a11b3a91e 100644
--- a/modules/mol/base/src/surface_handle.hh
+++ b/modules/mol/base/src/surface_handle.hh
@@ -70,7 +70,7 @@ public:
   // flip normals
   void Invert();
 
-  bool IsValid() const {return impl_;}
+  bool IsValid() const {return static_cast<bool>(impl_);}
 
   bool operator==(const SurfaceHandle& ref) const { return impl_==ref.impl_; }
 
diff --git a/modules/mol/mm/src/modeller.cc b/modules/mol/mm/src/modeller.cc
index 1a9da3094..03f1f72c4 100644
--- a/modules/mol/mm/src/modeller.cc
+++ b/modules/mol/mm/src/modeller.cc
@@ -91,9 +91,9 @@ void Modeller::LowerPrecision(ost::mol::EntityHandle& handle){
   for(ost::mol::AtomHandleList::iterator i = atom_list.begin();
       i != atom_list.end(); ++i){
     pos = i->GetPos();
-    truncated_pos[0] = Real(round(pos[0]*100))/100;
-    truncated_pos[1] = Real(round(pos[1]*100))/100;
-    truncated_pos[2] = Real(round(pos[2]*100))/100;
+    truncated_pos[0] = Real(round_real(pos[0]*100))/100;
+    truncated_pos[1] = Real(round_real(pos[1]*100))/100;
+    truncated_pos[2] = Real(round_real(pos[2]*100))/100;
     ed.SetAtomPos(*i,truncated_pos);
   }
   ed.UpdateICS();
-- 
GitLab