I want to run this by everyone before committing.  I personally think
that [compiling cleanly in opt mode with extra warnings enabled] is
important enough to be worth [wrapping tons of function arguments in
libmesh_debug_var()], but I want to give more than just John and I a
chance to chime in about the changes.  I didn't realize there were *so
many* such arguments.  I guess we've got lots of cases where a virtual
function has arguments which we intend for use by only some
subclasses, but for which we assert consistency in other subclasses.
---
Roy

---------- Forwarded message ----------
Date: Tue, 09 Aug 2011 14:52:26 -0400
From: Boyce Griffith <[email protected]>
To: Roy Stogner <[email protected]>
Cc: John Peterson <[email protected]>
Subject: Re: patch for eliminating warnings with -Wextra for optimized builds

I am attaching two patches to this email. They were generated against r4793. I hope you will find them useful.

The first patch (patch1.diff) defines libmesh_dbg_var() in libmesh_common.h and adds libmesh_dbg_var() calls to all function parameters that are used only in debugging mode. It also adds some guards around some variables that are used only in debug mode (see below for a summary).

The second patch (patch2.diff) changes macros libmesh_assert(), parallel_only(), and parallel_only_on() to evaluate to ((void) 0) if NDEBUG is defined. (The standard assert macro also appears to be defined in this manner on the versions of OS X, Solaris, and Linux that I have easy access to.) These changes eliminate all remaining compiler warnings on my workstation.

With these patches, libMesh compiles without any warnings with "-W -Wall -Werror" using METHOD=dbg and METHOD=opt on my system (OS X 10.5, gcc 4.5).

-- Boyce

===========================================================================

Summary of changes in patch1.diff
=================================

* transient_rb_construction.C line ~ 651:

variables trans_theta_expansion_in and trans_assembly_expansion_in are defined only when NDEBUG is undefined.

* parallel_mesh.C line ~ 617:

variables p_refinement_flag and min_pflag are defined only when NDEBUG is undefined. (FWIW, it seems like that assert isn't doing anything.)

* nemesis_io.C line ~ 412:

variables global_node_idx and owning_pid_idx are defined only when NDEBUG is undefined.

* inf_elem_builder.C line ~ 223:

variable ibn_size_before is defined only when NDEBUG is undefined.

* mesh_communication.C line ~ 1179:

variable n_elem_bcs_received is hit with libmesh_ignore().

* fem_context.C line ~ 870:

explicitly initialize neigh_n_dofs to equal zero (to fix an overzealous warning from the compiler).

* meshid.C

removed some an unused parameter (to handle_error()) and an unused variable (var_len).

On 8/9/11 12:57 PM, Roy Stogner wrote:


On Tue, 9 Aug 2011, Boyce Griffith wrote:

#ifndef NDEBUG
#define libmesh_dbg_use(a) (void) a
#else
#define libmesh_dbg_use(a) #endif

to avoid warnings like "warning: statement has no effect". (At least
this is true for g++ 4.5.)

No; this wouldn't be a macro for use anywhere except in the arguments
list for a function definition. And there we definitely want "int a",
not "int (void) a".
---
Roy
Index: include/utils/perf_log.h
===================================================================
--- include/utils/perf_log.h    (revision 4793)
+++ include/utils/perf_log.h    (working copy)
@@ -375,8 +375,8 @@
 
 
 inline
-void PerfLog::pop (const std::string &label,
-                  const std::string &header)
+void PerfLog::pop (const std::string &libmesh_dbg_var(label),
+                  const std::string &libmesh_dbg_var(header))
 {
   if (this->log_events)
     {
Index: include/numerics/petsc_vector.h
===================================================================
--- include/numerics/petsc_vector.h     (revision 4793)
+++ include/numerics/petsc_vector.h     (working copy)
@@ -806,7 +806,7 @@
                           const unsigned int n_local,
                           const std::vector<unsigned int>& ghost,
                           const bool fast,
-                           const ParallelType type)
+                           const ParallelType libmesh_dbg_var(type))
 {
   int ierr=0;
   int petsc_n=static_cast<int>(n);
Index: include/numerics/laspack_vector.h
===================================================================
--- include/numerics/laspack_vector.h   (revision 4793)
+++ include/numerics/laspack_vector.h   (working copy)
@@ -517,7 +517,7 @@
 template <typename T> 
 inline
 void LaspackVector<T>::init (const unsigned int n,
-                            const unsigned int n_local,
+                            const unsigned int libmesh_dbg_var(n_local),
                             const bool fast,
                              const ParallelType)
 {
@@ -564,7 +564,7 @@
 inline
 void LaspackVector<T>::init (const unsigned int n,
                             const unsigned int n_local,
-                            const std::vector<unsigned int>& ghost,
+                            const std::vector<unsigned int>& 
libmesh_dbg_var(ghost),
                             const bool fast,
                              const ParallelType type)
 {
Index: include/geom/edge_edge2.h
===================================================================
--- include/geom/edge_edge2.h   (revision 4793)
+++ include/geom/edge_edge2.h   (working copy)
@@ -60,7 +60,7 @@
    * nodes and neighbors for which storage will be allocated.
    */
   Edge2 (const unsigned int nn,
-        const unsigned int ns,
+        const unsigned int libmesh_dbg_var(ns),
         Elem* p) :
     Edge(nn, p) { libmesh_assert (ns == 0); }
 
Index: include/geom/edge_edge3.h
===================================================================
--- include/geom/edge_edge3.h   (revision 4793)
+++ include/geom/edge_edge3.h   (working copy)
@@ -59,7 +59,7 @@
    * nodes and neighbors for which storage will be allocated.
    */
   Edge3 (const unsigned int nn,
-        const unsigned int ns,
+        const unsigned int libmesh_dbg_var(ns),
         Elem* p) :
     Edge(nn, p) { libmesh_assert (ns == 0); }
 
Index: include/geom/edge_edge4.h
===================================================================
--- include/geom/edge_edge4.h   (revision 4793)
+++ include/geom/edge_edge4.h   (working copy)
@@ -56,7 +56,7 @@
    * nodes and neighbors for which storage will be allocated.
    */
   Edge4(const unsigned int nn,
-        const unsigned int ns,
+        const unsigned int libmesh_dbg_var(ns),
        Elem* p) :
     Edge(nn, p) { libmesh_assert (ns == 0); }
 
Index: include/base/libmesh_common.h
===================================================================
--- include/base/libmesh_common.h       (revision 4793)
+++ include/base/libmesh_common.h       (working copy)
@@ -246,6 +246,14 @@
 #  define libmesh_stop()     do { if (libMesh::n_processors() == 1) { 
libmesh_here(); libMesh::out << "WARNING:  libmesh_stop() does not work without 
the <csignal> header file!" << std::endl; } } while(0)
 #endif
 
+// The libmesh_dbg_use() macro indicates that an argument to a function
+// is used only in debug mode (i.e., when NDEBUG is not defined).
+#ifndef NDEBUG
+#define libmesh_dbg_var(var) var
+#else
+#define libmesh_dbg_var(var) 
+#endif
+
 // The libmesh_assert() macro acts like C's assert(), but throws a 
 // libmesh_error() (including stack trace, etc) instead of just exiting
 #ifdef NDEBUG
Index: src/apps/amr.C
===================================================================
--- src/apps/amr.C      (revision 4793)
+++ src/apps/amr.C      (working copy)
@@ -112,7 +112,7 @@
 
 
 void assemble(EquationSystems& es,
-             const std::string& system_name)
+             const std::string& libmesh_dbg_var(system_name))
 {
   libmesh_assert (system_name == "primary");
   
Index: src/apps/meshid.C
===================================================================
--- src/apps/meshid.C   (revision 4793)
+++ src/apps/meshid.C   (working copy)
@@ -13,7 +13,7 @@
 #define SIDES   0x2
 #define NODES   0x1
 
-void handle_error(int error)
+void handle_error(int)
 {
   std::cout << "An error occured while working with the netCDF API" << 
std::endl;
 
@@ -74,7 +74,7 @@
   // Processing
   std::string var_name, dim_name;
   int status;
-  int nc_id, var_id, dim_id, var_len;
+  int nc_id, var_id, dim_id;
   size_t dim_len;
 
   status = nc_open (meshname, NC_WRITE, &nc_id);
Index: src/apps/projection.C
===================================================================
--- src/apps/projection.C       (revision 4793)
+++ src/apps/projection.C       (working copy)
@@ -55,7 +55,7 @@
 // Return the function value on the old mesh and solution
 Number fptr(const Point& p,
             const Parameters&,
-            const std::string& sys_name,
+            const std::string& libmesh_dbg_var(sys_name),
             const std::string& unknown_name)
 {
   libmesh_assert(sys_name == current_sys_name);
@@ -70,7 +70,7 @@
 // Return the function gradient on the old mesh and solution
 Gradient gptr(const Point& p,
               const Parameters&,
-              const std::string& sys_name,
+              const std::string& libmesh_dbg_var(sys_name),
               const std::string& unknown_name)
 {
   libmesh_assert(sys_name == current_sys_name);
Index: src/numerics/laspack_vector.C
===================================================================
--- src/numerics/laspack_vector.C       (revision 4793)
+++ src/numerics/laspack_vector.C       (working copy)
@@ -372,7 +372,7 @@
 
 template <typename T>
 void LaspackVector<T>::localize (NumericVector<T>& v_local_in,
-                                const std::vector<unsigned int>& send_list) 
const
+                                const std::vector<unsigned int>& 
libmesh_dbg_var(send_list)) const
 {
   // Make sure the NumericVector passed in is really a LaspackVector
   LaspackVector<T>* v_local =
@@ -387,9 +387,9 @@
 
 
 template <typename T>
-void LaspackVector<T>::localize (const unsigned int first_local_idx,
-                                const unsigned int last_local_idx,
-                                const std::vector<unsigned int>& send_list)
+void LaspackVector<T>::localize (const unsigned int 
libmesh_dbg_var(first_local_idx),
+                                const unsigned int 
libmesh_dbg_var(last_local_idx),
+                                const std::vector<unsigned int>& 
libmesh_dbg_var(send_list))
 {
   libmesh_assert (first_local_idx  == 0);
   libmesh_assert (last_local_idx+1 == this->size());
@@ -413,7 +413,7 @@
 
 template <typename T>
 void LaspackVector<T>::localize_to_one (std::vector<T>& v_local,
-                                       const unsigned int pid) const
+                                       const unsigned int 
libmesh_dbg_var(pid)) const
 {
   libmesh_assert (pid == 0);
 
Index: src/numerics/laspack_matrix.C
===================================================================
--- src/numerics/laspack_matrix.C       (revision 4793)
+++ src/numerics/laspack_matrix.C       (working copy)
@@ -126,11 +126,11 @@
 
 
 template <typename T> 
-void LaspackMatrix<T>::init (const unsigned int m,
-                            const unsigned int n,
-                            const unsigned int m_l,
-                            const unsigned int n_l,
-                            const unsigned int nnz,
+void LaspackMatrix<T>::init (const unsigned int libmesh_dbg_var(m),
+                            const unsigned int libmesh_dbg_var(n),
+                            const unsigned int libmesh_dbg_var(m_l),
+                            const unsigned int libmesh_dbg_var(n_l),
+                            const unsigned int libmesh_dbg_var(nnz),
                             const unsigned int)
 {
   // noz ignored...  only used for multiple processors!
Index: src/geom/cell_prism15.C
===================================================================
--- src/geom/cell_prism15.C     (revision 4793)
+++ src/geom/cell_prism15.C     (working copy)
@@ -258,7 +258,7 @@
 }
 
 
-void Prism15::connectivity(const unsigned int sc,
+void Prism15::connectivity(const unsigned int libmesh_dbg_var(sc),
                           const IOPackage iop,
                           std::vector<unsigned int>& conn) const
 {
Index: src/geom/face_tri3.C
===================================================================
--- src/geom/face_tri3.C        (revision 4793)
+++ src/geom/face_tri3.C        (working copy)
@@ -159,7 +159,7 @@
 }
 
 
-void Tri3::connectivity(const unsigned int sf,
+void Tri3::connectivity(const unsigned int libmesh_dbg_var(sf),
                        const IOPackage iop,
                        std::vector<unsigned int>& conn) const
 {
Index: src/geom/edge.C
===================================================================
--- src/geom/edge.C     (revision 4793)
+++ src/geom/edge.C     (working copy)
@@ -67,7 +67,7 @@
 
 
 unsigned int Edge::opposite_node(const unsigned int node,
-                                 const unsigned int side) const
+                                 const unsigned int libmesh_dbg_var(side)) 
const
 {
   libmesh_assert(node < 2);
   libmesh_assert(side < this->n_sides());
Index: src/geom/cell_inf_hex8.C
===================================================================
--- src/geom/cell_inf_hex8.C    (revision 4793)
+++ src/geom/cell_inf_hex8.C    (working copy)
@@ -218,7 +218,7 @@
 }
 
 
-void InfHex8::connectivity(const unsigned int sc,
+void InfHex8::connectivity(const unsigned int libmesh_dbg_var(sc),
                           const IOPackage iop,
                           std::vector<unsigned int>& conn) const
 {
Index: src/geom/cell_hex8.C
===================================================================
--- src/geom/cell_hex8.C        (revision 4793)
+++ src/geom/cell_hex8.C        (working copy)
@@ -216,7 +216,7 @@
   
 
 
-void Hex8::connectivity(const unsigned int sc,
+void Hex8::connectivity(const unsigned int libmesh_dbg_var(sc),
                        const IOPackage iop,
                        std::vector<unsigned int>& conn) const
 {
Index: src/geom/cell_tet4.C
===================================================================
--- src/geom/cell_tet4.C        (revision 4793)
+++ src/geom/cell_tet4.C        (working copy)
@@ -160,7 +160,7 @@
 }
 
 
-void Tet4::connectivity(const unsigned int sc,
+void Tet4::connectivity(const unsigned int libmesh_dbg_var(sc),
                        const IOPackage iop,
                        std::vector<unsigned int>& conn) const
 {
Index: src/geom/elem.C
===================================================================
--- src/geom/elem.C     (revision 4793)
+++ src/geom/elem.C     (working copy)
@@ -1148,7 +1148,7 @@
 
 
 
-bool Elem::is_child_on_edge(const unsigned int c,
+bool Elem::is_child_on_edge(const unsigned int libmesh_dbg_var(c),
                             const unsigned int e) const
 {
   libmesh_assert (c < this->n_children());
Index: src/geom/face_inf_quad4.C
===================================================================
--- src/geom/face_inf_quad4.C   (revision 4793)
+++ src/geom/face_inf_quad4.C   (working copy)
@@ -205,7 +205,7 @@
 }
 
 
-void InfQuad4::connectivity(const unsigned int sf,
+void InfQuad4::connectivity(const unsigned int libmesh_dbg_var(sf),
                            const IOPackage iop,
                            std::vector<unsigned int>& conn) const
 {
Index: src/geom/cell_pyramid5.C
===================================================================
--- src/geom/cell_pyramid5.C    (revision 4793)
+++ src/geom/cell_pyramid5.C    (working copy)
@@ -217,7 +217,7 @@
 
 
 
-void Pyramid5::connectivity(const unsigned int sc,
+void Pyramid5::connectivity(const unsigned int libmesh_dbg_var(sc),
                            const IOPackage iop,
                            std::vector<unsigned int>& conn) const
 {
Index: src/geom/face_quad4.C
===================================================================
--- src/geom/face_quad4.C       (revision 4793)
+++ src/geom/face_quad4.C       (working copy)
@@ -193,7 +193,7 @@
 
 
 
-void Quad4::connectivity(const unsigned int sf,
+void Quad4::connectivity(const unsigned int libmesh_dbg_var(sf),
                         const IOPackage iop,
                         std::vector<unsigned int>& conn) const
 {
Index: src/geom/edge_inf_edge2.C
===================================================================
--- src/geom/edge_inf_edge2.C   (revision 4793)
+++ src/geom/edge_inf_edge2.C   (working copy)
@@ -59,13 +59,13 @@
 }
 
 bool InfEdge2::is_node_on_edge(const unsigned int,
-                              const unsigned int e) const
+                              const unsigned int libmesh_dbg_var(e)) const
 {
   libmesh_assert(e == 0);
   return true;
 }
 
-void InfEdge2::connectivity(const unsigned int se,
+void InfEdge2::connectivity(const unsigned int libmesh_dbg_var(se),
                            const IOPackage iop,
                            std::vector<unsigned int>& conn) const
 {
Index: src/geom/edge_edge2.C
===================================================================
--- src/geom/edge_edge2.C       (revision 4793)
+++ src/geom/edge_edge2.C       (working copy)
@@ -70,13 +70,13 @@
 }
 
 bool Edge2::is_node_on_edge(const unsigned int,
-                           const unsigned int e) const
+                           const unsigned int libmesh_dbg_var(e)) const
 {
   libmesh_assert(e == 0);
   return true;
 }
 
-void Edge2::connectivity(const unsigned int sc,
+void Edge2::connectivity(const unsigned int libmesh_dbg_var(sc),
                         const IOPackage iop,
                         std::vector<unsigned int>& conn) const
 {
Index: src/geom/edge_edge3.C
===================================================================
--- src/geom/edge_edge3.C       (revision 4793)
+++ src/geom/edge_edge3.C       (working copy)
@@ -76,7 +76,7 @@
 }
 
 bool Edge3::is_node_on_edge(const unsigned int,
-                           const unsigned int e) const
+                           const unsigned int libmesh_dbg_var(e)) const
 {
   libmesh_assert(e == 0);
   return true;
Index: src/geom/cell_inf_prism6.C
===================================================================
--- src/geom/cell_inf_prism6.C  (revision 4793)
+++ src/geom/cell_inf_prism6.C  (working copy)
@@ -216,7 +216,7 @@
 
 
 
-void InfPrism6::connectivity(const unsigned int sc,
+void InfPrism6::connectivity(const unsigned int libmesh_dbg_var(sc),
                             const IOPackage iop,
                             std::vector<unsigned int>& conn) const
 {
Index: src/geom/edge_edge4.C
===================================================================
--- src/geom/edge_edge4.C       (revision 4793)
+++ src/geom/edge_edge4.C       (working copy)
@@ -75,7 +75,7 @@
 }
 
 bool Edge4::is_node_on_edge(const unsigned int,
-                            const unsigned int e) const
+                            const unsigned int libmesh_dbg_var(e)) const
 {
   libmesh_assert(e == 0);
   return true;
Index: src/geom/cell_prism6.C
===================================================================
--- src/geom/cell_prism6.C      (revision 4793)
+++ src/geom/cell_prism6.C      (working copy)
@@ -229,7 +229,7 @@
 
 
 
-void Prism6::connectivity(const unsigned int sc,
+void Prism6::connectivity(const unsigned int libmesh_dbg_var(sc),
                          const IOPackage iop,
                          std::vector<unsigned int>& conn) const
 {
Index: src/systems/transient_rb_construction.C
===================================================================
--- src/systems/transient_rb_construction.C     (revision 4793)
+++ src/systems/transient_rb_construction.C     (working copy)
@@ -651,12 +651,13 @@
                                                       RBAssemblyExpansion& 
rb_assembly_expansion_in)
 {
   // Check that the theta and assembly objects are consistently sized
+#ifndef NDEBUG
   TransientRBThetaExpansion& trans_theta_expansion_in =
     libmesh_cast_ref<TransientRBThetaExpansion&>(rb_theta_expansion_in);
 
   TransientRBAssemblyExpansion& trans_assembly_expansion_in =
     libmesh_cast_ref<TransientRBAssemblyExpansion&>(rb_assembly_expansion_in);
-
+#endif
   libmesh_assert(trans_theta_expansion_in.get_Q_m() == 
trans_assembly_expansion_in.M_q_assembly_vector.size());
 
   // set the affine expansion objects
Index: src/systems/fem_context.C
===================================================================
--- src/systems/fem_context.C   (revision 4793)
+++ src/systems/fem_context.C   (working copy)
@@ -870,7 +870,7 @@
   if (compute_neighbor_values)
     sys.get_dof_map().dof_indices (neigh, neigh_dof_indices);
   unsigned int n_dofs = dof_indices.size();
-  unsigned int neigh_n_dofs;
+  unsigned int neigh_n_dofs = 0;
   if (compute_neighbor_values)
     neigh_n_dofs = neigh_dof_indices.size();
   unsigned int n_qoi = sys.qoi.size();
Index: src/fe/fe_clough_shape_0D.C
===================================================================
--- src/fe/fe_clough_shape_0D.C (revision 4793)
+++ src/fe/fe_clough_shape_0D.C (working copy)
@@ -33,7 +33,7 @@
 template <>
 Real FE<0,CLOUGH>::shape(const ElemType,
                           const Order,
-                          const unsigned int i,
+                          const unsigned int libmesh_dbg_var(i),
                           const Point&)
 {
   libmesh_assert (i < 1);
@@ -45,7 +45,7 @@
 template <>
 Real FE<0,CLOUGH>::shape(const Elem*,
                           const Order,
-                          const unsigned int i,
+                          const unsigned int libmesh_dbg_var(i),
                           const Point&)
 {
   libmesh_assert (i < 1);
Index: src/fe/fe_lagrange_shape_1D.C
===================================================================
--- src/fe/fe_lagrange_shape_1D.C       (revision 4793)
+++ src/fe/fe_lagrange_shape_1D.C       (working copy)
@@ -142,7 +142,7 @@
 Real FE<1,LAGRANGE>::shape_deriv(const ElemType,
                                 const Order order,
                                 const unsigned int i,
-                                const unsigned int j,
+                                const unsigned int libmesh_dbg_var(j),
                                 const Point& p)
 {
   // only d()/dxi in 1D!
@@ -256,7 +256,7 @@
 Real FE<1,LAGRANGE>::shape_second_deriv(const ElemType,
                                        const Order order,
                                        const unsigned int i,
-                                       const unsigned int j,
+                                       const unsigned int libmesh_dbg_var(j),
                                        const Point& p)
 {
   // Don't need to switch on j.  1D shape functions
Index: src/fe/fe_xyz_shape_0D.C
===================================================================
--- src/fe/fe_xyz_shape_0D.C    (revision 4793)
+++ src/fe/fe_xyz_shape_0D.C    (working copy)
@@ -33,7 +33,7 @@
 template <>
 Real FE<0,XYZ>::shape(const ElemType,
                           const Order,
-                          const unsigned int i,
+                          const unsigned int libmesh_dbg_var(i),
                           const Point&)
 {
   libmesh_assert (i < 1);
@@ -45,7 +45,7 @@
 template <>
 Real FE<0,XYZ>::shape(const Elem*,
                           const Order,
-                          const unsigned int i,
+                          const unsigned int libmesh_dbg_var(i),
                           const Point&)
 {
   libmesh_assert (i < 1);
Index: src/fe/fe_szabab_shape_0D.C
===================================================================
--- src/fe/fe_szabab_shape_0D.C (revision 4793)
+++ src/fe/fe_szabab_shape_0D.C (working copy)
@@ -33,7 +33,7 @@
 template <>
 Real FE<0,SZABAB>::shape(const ElemType,
                           const Order,
-                          const unsigned int i,
+                          const unsigned int libmesh_dbg_var(i),
                           const Point&)
 {
   libmesh_assert (i < 1);
@@ -45,7 +45,7 @@
 template <>
 Real FE<0,SZABAB>::shape(const Elem*,
                           const Order,
-                          const unsigned int i,
+                          const unsigned int libmesh_dbg_var(i),
                           const Point&)
 {
   libmesh_assert (i < 1);
Index: src/fe/fe_hierarchic_shape_1D.C
===================================================================
--- src/fe/fe_hierarchic_shape_1D.C     (revision 4793)
+++ src/fe/fe_hierarchic_shape_1D.C     (working copy)
@@ -33,7 +33,7 @@
 
 template <>
 Real FE<1,HIERARCHIC>::shape(const ElemType,
-                            const Order order,
+                            const Order libmesh_dbg_var(order),
                             const unsigned int i,
                             const Point& p)
 {
@@ -114,9 +114,9 @@
 
 template <>
 Real FE<1,HIERARCHIC>::shape_deriv(const ElemType,
-                                  const Order order,
+                                  const Order libmesh_dbg_var(order),
                                   const unsigned int i,
-                                  const unsigned int j,
+                                  const unsigned int libmesh_dbg_var(j),
                                   const Point& p)
 {
   // only d()/dxi in 1D!
@@ -200,9 +200,9 @@
 
 template <>
 Real FE<1,HIERARCHIC>::shape_second_deriv(const ElemType,
-                                         const Order order,
+                                         const Order libmesh_dbg_var(order),
                                          const unsigned int i,
-                                         const unsigned int j,
+                                         const unsigned int libmesh_dbg_var(j),
                                          const Point& p)
 {
   // only d2()/d2xi in 1D!
Index: src/fe/fe_monomial_shape_0D.C
===================================================================
--- src/fe/fe_monomial_shape_0D.C       (revision 4793)
+++ src/fe/fe_monomial_shape_0D.C       (working copy)
@@ -33,7 +33,7 @@
 template <>
 Real FE<0,MONOMIAL>::shape(const ElemType,
                           const Order,
-                          const unsigned int i,
+                          const unsigned int libmesh_dbg_var(i),
                           const Point&)
 {
   libmesh_assert (i < 1);
@@ -45,7 +45,7 @@
 template <>
 Real FE<0,MONOMIAL>::shape(const Elem*,
                           const Order,
-                          const unsigned int i,
+                          const unsigned int libmesh_dbg_var(i),
                           const Point&)
 {
   libmesh_assert (i < 1);
Index: src/fe/fe_lagrange_shape_0D.C
===================================================================
--- src/fe/fe_lagrange_shape_0D.C       (revision 4793)
+++ src/fe/fe_lagrange_shape_0D.C       (working copy)
@@ -33,7 +33,7 @@
 template <>
 Real FE<0,LAGRANGE>::shape(const ElemType,
                           const Order,
-                          const unsigned int i,
+                          const unsigned int libmesh_dbg_var(i),
                           const Point&)
 {
   libmesh_assert (i < 1);
@@ -45,7 +45,7 @@
 template <>
 Real FE<0,LAGRANGE>::shape(const Elem*,
                           const Order,
-                          const unsigned int i,
+                          const unsigned int libmesh_dbg_var(i),
                           const Point&)
 {
   libmesh_assert (i < 1);
Index: src/fe/fe_xyz_shape_3D.C
===================================================================
--- src/fe/fe_xyz_shape_3D.C    (revision 4793)
+++ src/fe/fe_xyz_shape_3D.C    (working copy)
@@ -59,7 +59,7 @@
 
 template <>
 Real FE<3,XYZ>::shape(const Elem* elem,
-                     const Order order,
+                     const Order libmesh_dbg_var(order),
                      const unsigned int i,
                      const Point& p)
 {
@@ -258,7 +258,7 @@
 
 template <>
 Real FE<3,XYZ>::shape_deriv(const Elem* elem,
-                           const Order order,
+                           const Order libmesh_dbg_var(order),
                            const unsigned int i,
                            const unsigned int j,
                            const Point& p)
@@ -739,7 +739,7 @@
 
 template <>
 Real FE<3,XYZ>::shape_second_deriv(const Elem* elem,
-                                  const Order order,
+                                  const Order libmesh_dbg_var(order),
                                   const unsigned int i,
                                   const unsigned int j,
                                   const Point& p)
Index: src/fe/fe_hierarchic_shape_0D.C
===================================================================
--- src/fe/fe_hierarchic_shape_0D.C     (revision 4793)
+++ src/fe/fe_hierarchic_shape_0D.C     (working copy)
@@ -33,7 +33,7 @@
 template <>
 Real FE<0,HIERARCHIC>::shape(const ElemType,
                           const Order,
-                          const unsigned int i,
+                          const unsigned int libmesh_dbg_var(i),
                           const Point&)
 {
   libmesh_assert (i < 1);
@@ -45,7 +45,7 @@
 template <>
 Real FE<0,HIERARCHIC>::shape(const Elem*,
                           const Order,
-                          const unsigned int i,
+                          const unsigned int libmesh_dbg_var(i),
                           const Point&)
 {
   libmesh_assert (i < 1);
Index: src/fe/inf_fe.C
===================================================================
--- src/fe/inf_fe.C     (revision 4793)
+++ src/fe/inf_fe.C     (working copy)
@@ -291,7 +291,7 @@
 
 
 template <unsigned int Dim, FEFamily T_radial, InfMapType T_map>
-void InfFE<Dim,T_radial,T_map>::init_radial_shape_functions(const Elem* 
inf_elem)
+void InfFE<Dim,T_radial,T_map>::init_radial_shape_functions(const Elem* 
libmesh_dbg_var(inf_elem))
 {
   libmesh_assert (radial_qrule != NULL);
   libmesh_assert (inf_elem     != NULL);
Index: src/fe/fe_monomial_shape_3D.C
===================================================================
--- src/fe/fe_monomial_shape_3D.C       (revision 4793)
+++ src/fe/fe_monomial_shape_3D.C       (working copy)
@@ -32,7 +32,7 @@
 
 template <>
 Real FE<3,MONOMIAL>::shape(const ElemType,
-                          const Order order,
+                          const Order libmesh_dbg_var(order),
                           const unsigned int i,
                           const Point& p)
 {
@@ -201,7 +201,7 @@
 
 template <>
 Real FE<3,MONOMIAL>::shape_deriv(const ElemType,
-                                const Order order,
+                                const Order libmesh_dbg_var(order),
                                 const unsigned int i,
                                 const unsigned int j,
                                 const Point& p)
@@ -652,7 +652,7 @@
 
 template <>
 Real FE<3,MONOMIAL>::shape_second_deriv(const ElemType,
-                                       const Order order,
+                                       const Order libmesh_dbg_var(order),
                                        const unsigned int i,
                                        const unsigned int j,
                                        const Point& p)
Index: src/fe/fe_bernstein_shape_1D.C
===================================================================
--- src/fe/fe_bernstein_shape_1D.C      (revision 4793)
+++ src/fe/fe_bernstein_shape_1D.C      (working copy)
@@ -212,7 +212,7 @@
 Real FE<1,BERNSTEIN>::shape_deriv(const ElemType,
                                  const Order order,
                                  const unsigned int i,
-                                 const unsigned int j,
+                                 const unsigned int libmesh_dbg_var(j),
                                  const Point& p)
 {
   // only d()/dxi in 1D!
Index: src/fe/fe_xyz_shape_2D.C
===================================================================
--- src/fe/fe_xyz_shape_2D.C    (revision 4793)
+++ src/fe/fe_xyz_shape_2D.C    (working copy)
@@ -59,7 +59,7 @@
 
 template <>
 Real FE<2,XYZ>::shape(const Elem* elem,
-                     const Order order,
+                     const Order libmesh_dbg_var(order),
                      const unsigned int i,
                      const Point& p)
 {
@@ -188,7 +188,7 @@
 
 template <>
 Real FE<2,XYZ>::shape_deriv(const Elem* elem,
-                           const Order order,
+                           const Order libmesh_dbg_var(order),
                            const unsigned int i,
                            const unsigned int j,
                            const Point& p)
@@ -400,7 +400,7 @@
 
 template <>
 Real FE<2,XYZ>::shape_second_deriv(const Elem* elem,
-                                  const Order order,
+                                  const Order libmesh_dbg_var(order),
                                   const unsigned int i,
                                   const unsigned int j,
                                   const Point& p)
Index: src/fe/fe_hermite_shape_0D.C
===================================================================
--- src/fe/fe_hermite_shape_0D.C        (revision 4793)
+++ src/fe/fe_hermite_shape_0D.C        (working copy)
@@ -33,7 +33,7 @@
 template <>
 Real FE<0,HERMITE>::shape(const ElemType,
                           const Order,
-                          const unsigned int i,
+                          const unsigned int libmesh_dbg_var(i),
                           const Point&)
 {
   libmesh_assert (i < 1);
@@ -45,7 +45,7 @@
 template <>
 Real FE<0,HERMITE>::shape(const Elem*,
                           const Order,
-                          const unsigned int i,
+                          const unsigned int libmesh_dbg_var(i),
                           const Point&)
 {
   libmesh_assert (i < 1);
Index: src/fe/fe_monomial_shape_2D.C
===================================================================
--- src/fe/fe_monomial_shape_2D.C       (revision 4793)
+++ src/fe/fe_monomial_shape_2D.C       (working copy)
@@ -32,7 +32,7 @@
 
 template <>
 Real FE<2,MONOMIAL>::shape(const ElemType,
-                          const Order order,
+                          const Order libmesh_dbg_var(order),
                           const unsigned int i,
                           const Point& p)
 {
@@ -133,7 +133,7 @@
 
 template <>
 Real FE<2,MONOMIAL>::shape_deriv(const ElemType,
-                                const Order order,
+                                const Order libmesh_dbg_var(order),
                                 const unsigned int i,
                                 const unsigned int j,
                                 const Point& p)
@@ -318,7 +318,7 @@
 
 template <>
 Real FE<2,MONOMIAL>::shape_second_deriv(const ElemType,
-                                       const Order order,
+                                       const Order libmesh_dbg_var(order),
                                        const unsigned int i,
                                        const unsigned int j,
                                        const Point& p)
Index: src/fe/fe_bernstein_shape_0D.C
===================================================================
--- src/fe/fe_bernstein_shape_0D.C      (revision 4793)
+++ src/fe/fe_bernstein_shape_0D.C      (working copy)
@@ -33,7 +33,7 @@
 template <>
 Real FE<0,BERNSTEIN>::shape(const ElemType,
                           const Order,
-                          const unsigned int i,
+                          const unsigned int libmesh_dbg_var(i),
                           const Point&)
 {
   libmesh_assert (i < 1);
@@ -45,7 +45,7 @@
 template <>
 Real FE<0,BERNSTEIN>::shape(const Elem*,
                           const Order,
-                          const unsigned int i,
+                          const unsigned int libmesh_dbg_var(i),
                           const Point&)
 {
   libmesh_assert (i < 1);
Index: src/fe/fe_xyz_shape_1D.C
===================================================================
--- src/fe/fe_xyz_shape_1D.C    (revision 4793)
+++ src/fe/fe_xyz_shape_1D.C    (working copy)
@@ -59,7 +59,7 @@
 
 template <>
 Real FE<1,XYZ>::shape(const Elem* elem,
-                     const Order order,
+                     const Order libmesh_dbg_var(order),
                      const unsigned int i,
                      const Point& p)
 {
@@ -135,9 +135,9 @@
 
 template <>
 Real FE<1,XYZ>::shape_deriv(const Elem* elem,
-                           const Order order,
+                           const Order libmesh_dbg_var(order),
                            const unsigned int i,
-                           const unsigned int j,
+                           const unsigned int libmesh_dbg_var(j),
                            const Point& p)
 {
   libmesh_assert (elem != NULL);
@@ -215,9 +215,9 @@
 
 template <>
 Real FE<1,XYZ>::shape_second_deriv(const Elem* elem,
-                                  const Order order,
+                                  const Order libmesh_dbg_var(order),
                                   const unsigned int i,
-                                  const unsigned int j,
+                                  const unsigned int libmesh_dbg_var(j),
                                   const Point& p)
 {
   libmesh_assert (elem != NULL);
Index: src/fe/fe_szabab_shape_1D.C
===================================================================
--- src/fe/fe_szabab_shape_1D.C (revision 4793)
+++ src/fe/fe_szabab_shape_1D.C (working copy)
@@ -35,7 +35,7 @@
 
 template <>
 Real FE<1,SZABAB>::shape(const ElemType,
-                        const Order order,
+                        const Order libmesh_dbg_var(order),
                         const unsigned int i,
                         const Point& p)
 {
@@ -103,9 +103,9 @@
 
 template <>
 Real FE<1,SZABAB>::shape_deriv(const ElemType,
-                              const Order order,
+                              const Order libmesh_dbg_var(order),
                               const unsigned int i,
-                              const unsigned int j,
+                              const unsigned int libmesh_dbg_var(j),
                               const Point& p)
 {
   // only d()/dxi in 1D!  
Index: src/fe/fe_monomial_shape_1D.C
===================================================================
--- src/fe/fe_monomial_shape_1D.C       (revision 4793)
+++ src/fe/fe_monomial_shape_1D.C       (working copy)
@@ -32,7 +32,7 @@
 
 template <>
 Real FE<1,MONOMIAL>::shape(const ElemType,
-                          const Order order,
+                          const Order libmesh_dbg_var(order),
                           const unsigned int i,
                           const Point& p)
 {
@@ -86,9 +86,9 @@
 
 template <>
 Real FE<1,MONOMIAL>::shape_deriv(const ElemType,
-                                const Order order,
+                                const Order libmesh_dbg_var(order),
                                 const unsigned int i,
-                                const unsigned int j,
+                                const unsigned int libmesh_dbg_var(j),
                                 const Point& p)
 {
   // only d()/dxi in 1D!
@@ -147,9 +147,9 @@
 
 template <>
 Real FE<1,MONOMIAL>::shape_second_deriv(const ElemType,
-                                       const Order order,
+                                       const Order libmesh_dbg_var(order),
                                        const unsigned int i,
-                                       const unsigned int j,
+                                       const unsigned int libmesh_dbg_var(j),
                                        const Point& p)
 {
   // only d()/dxi in 1D!
Index: src/mesh/parallel_mesh.C
===================================================================
--- src/mesh/parallel_mesh.C    (revision 4793)
+++ src/mesh/parallel_mesh.C    (working copy)
@@ -617,15 +617,19 @@
 
       unsigned int refinement_flag   = elem ?
         static_cast<unsigned int> (elem->refinement_flag()) : 
libMesh::invalid_uint;
+#ifndef NDEBUG
       unsigned int p_refinement_flag = elem ?
         static_cast<unsigned int> (elem->p_refinement_flag()) : 
libMesh::invalid_uint;
+#endif
 
       unsigned int min_rflag = refinement_flag;
       Parallel::min(min_rflag);
       // All processors with this element should agree on flag
       libmesh_assert (!elem || min_rflag == refinement_flag);
 
+#ifndef NDEBUG
       unsigned int min_pflag = p_refinement_flag;
+#endif
       // All processors with this element should agree on flag
       libmesh_assert (!elem || min_pflag == p_refinement_flag);
     }
Index: src/mesh/mesh_communication.C
===================================================================
--- src/mesh/mesh_communication.C       (revision 4793)
+++ src/mesh/mesh_communication.C       (working copy)
@@ -1179,6 +1179,9 @@
          
////////////////////////////////////////////////////////////////////////////////
          const unsigned int n_node_bcs_received = elements_received.back(); 
elements_received.pop_back();
          const unsigned int n_elem_bcs_received = elements_received.back(); 
elements_received.pop_back();
+#ifdef NDEBUG
+          libmesh_ignore(n_elem_bcs_received);
+#endif
          const unsigned int n_elements_received = elements_received.back(); 
elements_received.pop_back();
          
          // counter into the bc/element connectivty buffer
Index: src/mesh/xdr_io.C
===================================================================
--- src/mesh/xdr_io.C   (revision 4793)
+++ src/mesh/xdr_io.C   (working copy)
@@ -255,7 +255,7 @@
 
 
 
-void XdrIO::write_serialized_connectivity (Xdr &io, const unsigned int n_elem) 
const
+void XdrIO::write_serialized_connectivity (Xdr &io, const unsigned int 
libmesh_dbg_var(n_elem)) const
 {
   libmesh_assert (io.writing());
   
Index: src/mesh/nemesis_io.C
===================================================================
--- src/mesh/nemesis_io.C       (revision 4793)
+++ src/mesh/nemesis_io.C       (working copy)
@@ -412,10 +412,11 @@
   // computed and the current processor's ID.
   for (unsigned int i=0; i<to_uint(nemhelper->num_internal_nodes); ++i)
     {
-      const unsigned int 
-       local_node_idx  = nemhelper->node_mapi[i]-1,
-       global_node_idx = nemhelper->node_num_map[local_node_idx]-1,
-       owning_pid_idx  = node_ownership[local_node_idx];
+      const unsigned int local_node_idx  = nemhelper->node_mapi[i]-1;
+#ifndef NDEBUG
+      const unsigned int global_node_idx = 
nemhelper->node_num_map[local_node_idx]-1;
+      const unsigned int owning_pid_idx  = node_ownership[local_node_idx];
+#endif
 
       // an internal node we do not own? huh??
       libmesh_assert (owning_pid_idx == libMesh::processor_id());
Index: src/mesh/mesh_refinement.C
===================================================================
--- src/mesh/mesh_refinement.C  (revision 4793)
+++ src/mesh/mesh_refinement.C  (working copy)
@@ -295,7 +295,7 @@
 
 
 
-bool MeshRefinement::test_level_one (bool libmesh_assert_pass)
+bool MeshRefinement::test_level_one (bool libmesh_dbg_var(libmesh_assert_pass))
 {
   // This function must be run on all processors at once
   parallel_only();
@@ -359,7 +359,7 @@
 
 
 
-bool MeshRefinement::test_unflagged (bool libmesh_assert_pass)
+bool MeshRefinement::test_unflagged (bool libmesh_dbg_var(libmesh_assert_pass))
 {
   // This function must be run on all processors at once
   parallel_only();
Index: src/mesh/inf_elem_builder.C
===================================================================
--- src/mesh/inf_elem_builder.C (revision 4793)
+++ src/mesh/inf_elem_builder.C (working copy)
@@ -223,7 +223,9 @@
       // front, while to leftovers are @e not deleted.  Instead,
       // it returns a pointer to the end of the unique range.
       //TODO:[BSK] int_ibn_size_before is not the same type as unique_size!
+#ifndef NDEBUG
       const unsigned int ibn_size_before = inner_boundary_node_numbers.size();
+#endif
       std::sort (inner_boundary_node_numbers.begin(), 
inner_boundary_node_numbers.end());
       std::vector<unsigned int>::iterator unique_end = 
          std::unique (inner_boundary_node_numbers.begin(), 
inner_boundary_node_numbers.end());
Index: src/solvers/petsc_diff_solver.C
===================================================================
--- src/solvers/petsc_diff_solver.C     (revision 4793)
+++ src/solvers/petsc_diff_solver.C     (working copy)
@@ -111,7 +111,7 @@
 
 
 PetscErrorCode
-__libmesh_petsc_diff_solver_jacobian (SNES, Vec x, Mat *j, Mat *pc,
+__libmesh_petsc_diff_solver_jacobian (SNES, Vec x, Mat *libmesh_dbg_var(j), 
Mat *pc,
                                       MatStructure *msflag, void *ctx)
 {
   libmesh_assert (x   != NULL);
Index: include/base/libmesh_common.h
===================================================================
--- include/base/libmesh_common.h       (revision 4793)
+++ include/base/libmesh_common.h       (working copy)
@@ -246,10 +246,18 @@
 #  define libmesh_stop()     do { if (libMesh::n_processors() == 1) { 
libmesh_here(); libMesh::out << "WARNING:  libmesh_stop() does not work without 
the <csignal> header file!" << std::endl; } } while(0)
 #endif
 
+// The libmesh_dbg_use() macro indicates that an argument to a function
+// is used only in debug mode (i.e., when NDEBUG is not defined).
+#ifndef NDEBUG
+#define libmesh_dbg_var(var) var
+#else
+#define libmesh_dbg_var(var) 
+#endif
+
 // The libmesh_assert() macro acts like C's assert(), but throws a 
 // libmesh_error() (including stack trace, etc) instead of just exiting
 #ifdef NDEBUG
-#define libmesh_assert(asserted) 
+#define libmesh_assert(asserted)  ((void) 0)
 #else
 #define libmesh_assert(asserted)  do { if (!(asserted)) { libMesh::err << 
"Assertion `" #asserted "' failed." << std::endl; libmesh_error(); } } while(0)
 #endif
Index: include/parallel/parallel.h
===================================================================
--- include/parallel/parallel.h (revision 4793)
+++ include/parallel/parallel.h (working copy)
@@ -45,7 +45,7 @@
     libmesh_assert(Parallel::verify(std::string(__FILE__))); \
     libmesh_assert(Parallel::verify(__LINE__)); } while (0)
 #else
-  #define parallel_only()
+  #define parallel_only()  ((void) 0)
 #endif
 
 // Macro to identify and debug functions which should only be called in
@@ -58,7 +58,7 @@
     libmesh_assert(Parallel::verify(std::string(__FILE__), comm_arg)); \
     libmesh_assert(Parallel::verify(__LINE__), comm_arg); } while (0)
 #else
-  #define parallel_only_on(comm_arg)
+  #define parallel_only_on(comm_arg)  ((void) 0)
 #endif
 
 /**
------------------------------------------------------------------------------
uberSVN's rich system and user administration capabilities and model 
configuration take the hassle out of deploying and managing Subversion and 
the tools developers use with it. Learn more about uberSVN and get a free 
download at:  http://p.sf.net/sfu/wandisco-dev2dev
_______________________________________________
Libmesh-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libmesh-devel

Reply via email to