From: Matthias Maier Date: Wed, 16 Oct 2013 23:32:40 +0000 (+0000) Subject: Workaround for a constexpr bug in gcc-4.8* on Windows and Mac X-Git-Tag: v8.1.0~570^2~34 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3af40afb002b37080e3d65798367d5e26b5962e6;p=dealii.git Workaround for a constexpr bug in gcc-4.8* on Windows and Mac git-svn-id: https://svn.dealii.org/branches/branch_port_the_testsuite@31274 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/cmake/checks/check_03_compiler_bugs.cmake b/deal.II/cmake/checks/check_03_compiler_bugs.cmake index 66d9b54c2b..f2cc702cb0 100644 --- a/deal.II/cmake/checks/check_03_compiler_bugs.cmake +++ b/deal.II/cmake/checks/check_03_compiler_bugs.cmake @@ -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() diff --git a/deal.II/include/deal.II/base/config.h.in b/deal.II/include/deal.II/base/config.h.in index 8c5dba2a0d..571abc27f3 100644 --- a/deal.II/include/deal.II/base/config.h.in +++ b/deal.II/include/deal.II/base/config.h.in @@ -191,7 +191,7 @@ /**************************************** - * 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 @@ -227,6 +227,12 @@ */ #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: * diff --git a/deal.II/include/deal.II/base/geometry_info.h b/deal.II/include/deal.II/base/geometry_info.h index ced3b187de..2b8b62331f 100644 --- a/deal.II/include/deal.II/base/geometry_info.h +++ b/deal.II/include/deal.II/base/geometry_info.h @@ -2169,11 +2169,15 @@ struct GeometryInfo * in the glossary). */ template - static - void + static void alternating_form_at_vertices - (const Point (&vertices)[vertices_per_cell], - Tensor (&forms)[vertices_per_cell]); +#ifndef DEAL_II_CONSTEXPR_BUG + (const Point (&vertices)[vertices_per_cell], + Tensor (&forms)[vertices_per_cell]); +#else + (const Point *vertices, + Tensor *forms); +#endif /** * For each face of the reference diff --git a/deal.II/source/base/geometry_info.cc b/deal.II/source/base/geometry_info.cc index 6569451117..7bb041574e 100644 --- a/deal.II/source/base/geometry_info.cc +++ b/deal.II/source/base/geometry_info.cc @@ -1842,8 +1842,13 @@ template void GeometryInfo:: alternating_form_at_vertices -(const Point (&vertices)[vertices_per_cell], - Tensor (&forms)[vertices_per_cell]) +#ifndef DEAL_II_CONSTEXPR_BUG + (const Point (&vertices)[vertices_per_cell], + Tensor (&forms)[vertices_per_cell]) +#else + (const Point *vertices, + Tensor *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 ; diff --git a/deal.II/source/grid/grid_tools.cc b/deal.II/source/grid/grid_tools.cc index 9ad7a35955..df146a150b 100644 --- a/deal.II/source/grid/grid_tools.cc +++ b/deal.II/source/grid/grid_tools.cc @@ -1557,8 +1557,8 @@ next_cell: for (unsigned int i=0; i::vertices_per_cell; ++i) parent_vertices[i] = object->vertex(i); - GeometryInfo::template alternating_form_at_vertices - (parent_vertices, parent_alternating_forms); + GeometryInfo::alternating_form_at_vertices (parent_vertices, + parent_alternating_forms); const Tensor average_parent_alternating_form @@ -1595,8 +1595,8 @@ next_cell: = object_mid_point; for (unsigned int c=0; cn_children(); ++c) - GeometryInfo::template alternating_form_at_vertices - (child_vertices[c], child_alternating_forms[c]); + GeometryInfo::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 parent_alternating_forms [GeometryInfo::vertices_per_cell]; - GeometryInfo::template alternating_form_at_vertices - (parent_vertices, parent_alternating_forms); + GeometryInfo::alternating_form_at_vertices (parent_vertices, + parent_alternating_forms); Point child_vertices [GeometryInfo::max_children_per_cell] @@ -1909,8 +1909,8 @@ next_cell: [GeometryInfo::vertices_per_cell]; for (unsigned int c=0; cn_children(); ++c) - GeometryInfo::template alternating_form_at_vertices - (child_vertices[c], child_alternating_forms[c]); + GeometryInfo::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; cn_children(); ++c) @@ -1931,8 +1931,8 @@ next_cell: = object_mid_point; for (unsigned int c=0; cn_children(); ++c) - GeometryInfo::template alternating_form_at_vertices - (child_vertices[c], child_alternating_forms[c]); + GeometryInfo::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; cn_children(); ++c)