]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Workaround for a constexpr bug in gcc-4.8* on Windows and Mac
authormaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 16 Oct 2013 23:32:40 +0000 (23:32 +0000)
committermaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 16 Oct 2013 23:32:40 +0000 (23:32 +0000)
git-svn-id: https://svn.dealii.org/branches/branch_port_the_testsuite@31274 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/cmake/checks/check_03_compiler_bugs.cmake
deal.II/include/deal.II/base/config.h.in
deal.II/include/deal.II/base/geometry_info.h
deal.II/source/base/geometry_info.cc
deal.II/source/grid/grid_tools.cc

index 66d9b54c2b7fbb3c2846905255e7826ec8dacd18..f2cc702cb08032b83621a499050cdf9fbf79a428 100644 (file)
@@ -323,3 +323,18 @@ IF(DEAL_II_ICC_NUMERICLIMITS_BUG)
   SET(DEAL_II_USE_CXX11 FALSE)
 ENDIF()
 
+#
+# gcc-4.8.1 has some problems with the constexpr "vertices_per_cell" in the
+# definition of alternating_form_at_vertices.
+#
+# TODO: Write a unit test.
+#
+# For now, just enable the workaround for Windows targets
+#
+# - Matthias Maier, 2013
+#
+
+IF( CMAKE_SYSTEM_NAME MATCHES "CYGWIN"
+    OR CMAKE_SYSTEM_NAME MATCHES "Windows" )
+  SET(DEAL_II_CONSTEXPR_BUG TRUE)
+ENDIF()
index 8c5dba2a0de49ed9bdeb120f59422bf29b9950bf..571abc27f341370290ccc016032ab80fab3f2fd5 100644 (file)
 
 
 /****************************************
- * Configured in check_2_compiler_bugs: *
+ * Configured in check_3_compiler_bugs: *
  ****************************************/
 
 /* Defined if we have to work around a bug with some compilers that will not
  */
 #cmakedefine DEAL_II_BOOST_BIND_COMPILER_BUG
 
+/* Defined if the compiler incorrectly deduces a constexpr as not being a
+ * constant integral expression under certain optimization (notably
+ * gcc-4.8.1 on Windows and Mac)
+ */
+#cmakedefine DEAL_II_CONSTEXPR_BUG
+
 
 /*****************************************
  * Configured in configure_arpack.cmake: *
index ced3b187defddbc45b4e949bafb71df48ffce42d..2b8b62331f14a69bc852884291d5ea5b12fb8857 100644 (file)
@@ -2169,11 +2169,15 @@ struct GeometryInfo
    * in the glossary).
    */
   template <int spacedim>
-  static
-  void
+  static void
   alternating_form_at_vertices
-  (const Point<spacedim> (&vertices)[vertices_per_cell],
-   Tensor<spacedim-dim,spacedim> (&forms)[vertices_per_cell]);
+#ifndef DEAL_II_CONSTEXPR_BUG
+    (const Point<spacedim> (&vertices)[vertices_per_cell],
+     Tensor<spacedim-dim,spacedim> (&forms)[vertices_per_cell]);
+#else
+    (const Point<spacedim> *vertices,
+     Tensor<spacedim-dim,spacedim> *forms);
+#endif
 
   /**
    * For each face of the reference
index 6569451117892e39f132f8dbae4b30ad6a8dee47..7bb041574e01f783d82c30c8a3b105664ac0cec5 100644 (file)
@@ -1842,8 +1842,13 @@ template <int spacedim>
 void
 GeometryInfo<dim>::
 alternating_form_at_vertices
-(const Point<spacedim> (&vertices)[vertices_per_cell],
- Tensor<spacedim-dim,spacedim> (&forms)[vertices_per_cell])
+#ifndef DEAL_II_CONSTEXPR_BUG
+    (const Point<spacedim> (&vertices)[vertices_per_cell],
+     Tensor<spacedim-dim,spacedim> (&forms)[vertices_per_cell])
+#else
+    (const Point<spacedim> *vertices,
+     Tensor<spacedim-dim,spacedim> *forms)
+#endif
 {
   // for each of the vertices,
   // compute the alternating form
@@ -1901,32 +1906,48 @@ template
 void
 GeometryInfo<1>::
 alternating_form_at_vertices
-(const Point<1> (&vertices)[vertices_per_cell],
- Tensor<1-1,1> (&forms)[vertices_per_cell])
+#ifndef DEAL_II_CONSTEXPR_BUG
+(const Point<1> (&)[vertices_per_cell],
+ Tensor<1-1,1> (&)[vertices_per_cell])
+#else
+(const Point<1> *, Tensor<1-1,1> *)
+#endif
 ;
 
 template
 void
 GeometryInfo<1>::
 alternating_form_at_vertices
-(const Point<2> (&vertices)[vertices_per_cell],
- Tensor<2-1,2> (&forms)[vertices_per_cell])
+#ifndef DEAL_II_CONSTEXPR_BUG
+(const Point<2> (&)[vertices_per_cell],
+ Tensor<2-1,2> (&)[vertices_per_cell])
+#else
+(const Point<2> *, Tensor<2-1,2> *)
+#endif
 ;
 
 template
 void
 GeometryInfo<2>::
 alternating_form_at_vertices
+#ifndef DEAL_II_CONSTEXPR_BUG
 (const Point<2> (&vertices)[vertices_per_cell],
  Tensor<2-2,2> (&forms)[vertices_per_cell])
+#else
+(const Point<2> *, Tensor<2-2,2> *)
+#endif
 ;
 
 template
 void
 GeometryInfo<2>::
 alternating_form_at_vertices
+#ifndef DEAL_II_CONSTEXPR_BUG
 (const Point<3> (&vertices)[vertices_per_cell],
  Tensor<3-2,3> (&forms)[vertices_per_cell])
+#else
+(const Point<3> *, Tensor<3-2,3> *)
+#endif
 ;
 
 
@@ -1934,8 +1955,12 @@ template
 void
 GeometryInfo<3>::
 alternating_form_at_vertices
+#ifndef DEAL_II_CONSTEXPR_BUG
 (const Point<3> (&vertices)[vertices_per_cell],
  Tensor<3-3,3> (&forms)[vertices_per_cell])
+#else
+(const Point<3> *, Tensor<3-3,3> *)
+#endif
 ;
 
 
index 9ad7a3595570754e058a940854a1aca2797e92bb..df146a150b1dbbfb6bac450c64a5604b707bf1a5 100644 (file)
@@ -1557,8 +1557,8 @@ next_cell:
         for (unsigned int i=0; i<GeometryInfo<structdim>::vertices_per_cell; ++i)
           parent_vertices[i] = object->vertex(i);
 
-        GeometryInfo<structdim>::template alternating_form_at_vertices<spacedim>
-          (parent_vertices, parent_alternating_forms);
+        GeometryInfo<structdim>::alternating_form_at_vertices (parent_vertices,
+                                                               parent_alternating_forms);
 
         const Tensor<spacedim-structdim,spacedim>
         average_parent_alternating_form
@@ -1595,8 +1595,8 @@ next_cell:
             = object_mid_point;
 
         for (unsigned int c=0; c<object->n_children(); ++c)
-          GeometryInfo<structdim>::template alternating_form_at_vertices<spacedim>
-            (child_vertices[c], child_alternating_forms[c]);
+          GeometryInfo<structdim>::alternating_form_at_vertices (child_vertices[c],
+                                                                 child_alternating_forms[c]);
 
         // on a uniformly refined
         // hypercube object, the child
@@ -1893,8 +1893,8 @@ next_cell:
 
         Tensor<spacedim-structdim,spacedim> parent_alternating_forms
         [GeometryInfo<structdim>::vertices_per_cell];
-        GeometryInfo<structdim>::template alternating_form_at_vertices<spacedim>
-          (parent_vertices, parent_alternating_forms);
+        GeometryInfo<structdim>::alternating_form_at_vertices (parent_vertices,
+                                                               parent_alternating_forms);
 
         Point<spacedim> child_vertices
         [GeometryInfo<structdim>::max_children_per_cell]
@@ -1909,8 +1909,8 @@ next_cell:
         [GeometryInfo<structdim>::vertices_per_cell];
 
         for (unsigned int c=0; c<object->n_children(); ++c)
-          GeometryInfo<structdim>::template alternating_form_at_vertices<spacedim>
-            (child_vertices[c], child_alternating_forms[c]);
+          GeometryInfo<structdim>::alternating_form_at_vertices (child_vertices[c],
+                                                                 child_alternating_forms[c]);
 
         old_min_product = child_alternating_forms[0][0] * parent_alternating_forms[0];
         for (unsigned int c=0; c<object->n_children(); ++c)
@@ -1931,8 +1931,8 @@ next_cell:
             = object_mid_point;
 
         for (unsigned int c=0; c<object->n_children(); ++c)
-          GeometryInfo<structdim>::template alternating_form_at_vertices<spacedim>
-            (child_vertices[c], child_alternating_forms[c]);
+          GeometryInfo<structdim>::alternating_form_at_vertices (child_vertices[c],
+                                                                 child_alternating_forms[c]);
 
         new_min_product = child_alternating_forms[0][0] * parent_alternating_forms[0];
         for (unsigned int c=0; c<object->n_children(); ++c)

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.