From: wolf Date: Mon, 26 Feb 2001 13:03:44 +0000 (+0000) Subject: Work around a compiler bug in gcc2.95. (Takeover of fix from main branch.) X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=71d9a45e2cb7993996994cce55b28476e184e7a9;p=dealii-svn.git Work around a compiler bug in gcc2.95. (Takeover of fix from main branch.) git-svn-id: https://svn.dealii.org/branches/Branch-3-1@4031 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 8efd3bd745..1769b4a9b0 100644 --- a/deal.II/deal.II/include/grid/tria.h +++ b/deal.II/deal.II/include/grid/tria.h @@ -1589,8 +1589,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: @@ -1737,7 +1758,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/include/grid/tria_boundary.h b/deal.II/deal.II/include/grid/tria_boundary.h index 0e0f022091..4f294c2244 100644 --- a/deal.II/deal.II/include/grid/tria_boundary.h +++ b/deal.II/deal.II/include/grid/tria_boundary.h @@ -17,7 +17,11 @@ /*---------------------------- boundary-function.h ---------------------------*/ #include -#include +#include + + +template class Triangulation; + /** diff --git a/deal.II/deal.II/source/grid/tria.cc b/deal.II/deal.II/source/grid/tria.cc index 9401a3884f..d6e4040b6a 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();