]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Better document why we take a large argument by value. 4417/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Fri, 26 May 2017 15:37:58 +0000 (09:37 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Fri, 26 May 2017 15:37:58 +0000 (09:37 -0600)
This addresses an issue found by Coverity. We copy the argument intentionally.

include/deal.II/base/exceptions.h

index 5b80e219ddba589ecd50248cbdcf6f917a232860..4ed28c650b5872efb223613cf50822cf235593be 100644 (file)
@@ -265,16 +265,22 @@ namespace deal_II_exceptions
      * This routine does the main work for the exception generation mechanism
      * used in the <tt>Assert</tt> macro.
      *
+     * The actual exception object (the last argument) is typically an unnamed
+     * object created in place; because we modify it, we can't take it by
+     * const reference, and temporaries don't bind to non-const references.
+     * So take it by value (=copy it) -- the performance implications are
+     * pretty minimal anyway.
+     *
      * @ref ExceptionBase
      */
-    template <class exc>
-    void issue_error (ExceptionHandling handling,
-                      const char *file,
-                      int         line,
-                      const char *function,
-                      const char *cond,
-                      const char *exc_name,
-                      exc         e)
+    template <class ExceptionType>
+    void issue_error (ExceptionHandling  handling,
+                      const char       *file,
+                      int               line,
+                      const char       *function,
+                      const char       *cond,
+                      const char       *exc_name,
+                      ExceptionType     e)
     {
       // Fill the fields of the exception object
       e.set_fields (file, line, function, cond, exc_name);

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.