From: Wolfgang Bangerth Date: Mon, 26 Feb 2001 13:00:40 +0000 (+0000) Subject: Work around a bug in gcc 2.95 that prevented the compilation of tria_boundary.cc X-Git-Tag: v8.0.0~19684 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b0ca4fdde8e140a0de6d09cd73219213048f6b5d;p=dealii.git Work around a bug in gcc 2.95 that prevented the compilation of tria_boundary.cc git-svn-id: https://svn.dealii.org/trunk@4029 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/grid/tria.h b/deal.II/deal.II/include/grid/tria.h index 2828e3172d..7d3b39841d 100644 --- a/deal.II/deal.II/include/grid/tria.h +++ b/deal.II/deal.II/include/grid/tria.h @@ -1585,8 +1585,29 @@ class Triangulation : public TriaDimensionInfo, * declaration is used for the * default argument in * @p{set_boundary}. - */ - static const StraightBoundary straight_boundary; + * + * The proper way would have been + * to use a static object here, + * rather than a pointer to an + * object. However, we have to + * work around a bug in gcc2.95, + * where the compiler tries to + * instantiate @p{Triangulation} + * while instantiating + * @p{Boundary} (which it needs + * to do, since local typedefs + * are involved), but then tries + * to in turn instantiate + * @p{StraightBoundary} because + * of this member variable. This + * is not needed since the member + * variable is a static one, but + * the compiler tries anyway and + * finds that it can't since the + * base class @p{Boundary} is not + * yet complete... + */ + static const StraightBoundary *straight_boundary; public: @@ -1733,7 +1754,7 @@ class Triangulation : public TriaDimensionInfo, * straight line. */ void set_boundary (unsigned int number, - const Boundary &boundary_object = straight_boundary); + const Boundary &boundary_object = *straight_boundary); /** * Return a constant reference to diff --git a/deal.II/deal.II/source/grid/tria.cc b/deal.II/deal.II/source/grid/tria.cc index de52ea6c38..cfe83ed5b6 100644 --- a/deal.II/deal.II/source/grid/tria.cc +++ b/deal.II/deal.II/source/grid/tria.cc @@ -28,8 +28,19 @@ #include + +// initialize the @p{straight_boundary} pointer of the triangulation +// class. for the reasons why it is done like this, see the +// documentation of that member variable +namespace +{ + const StraightBoundary dummy_straight_boundary; +}; + + template -const StraightBoundary Triangulation::straight_boundary; +const StraightBoundary * +Triangulation::straight_boundary = &dummy_straight_boundary; @@ -41,8 +52,8 @@ Triangulation::Triangulation (const MeshSmoothing smooth_grid) : // set default boundary for all possible components for (unsigned int i=0;i<255;++i) { - boundary[i] = &straight_boundary; - straight_boundary.subscribe(); + boundary[i] = straight_boundary; + boundary[i]->subscribe(); } }; @@ -86,8 +97,8 @@ void Triangulation::clear () for (unsigned int i=0; i<255; ++i) { boundary[i]->unsubscribe (); - boundary[i] = &straight_boundary; - straight_boundary.subscribe (); + boundary[i] = straight_boundary; + boundary[i]->subscribe (); }; number_cache = TriaNumberCache();