[Dune] [#682] Minor bug in use of shared_ptr<> in mpicollectivecommunicationhh

Dune dune at dune-project.org
Fri Dec 4 21:30:52 CET 2009


THIS IS AN AUTOMATED MESSAGE, DO NOT REPLY.

A new Flyspray task has been opened.  Details are below. 

User who did this - Atgeirr Flø Rasmussen (atgeirr) 

Attached to Project - Dune
Summary - Minor bug in use of shared_ptr<> in mpicollectivecommunicationhh
Task Type - Bug Report
Category - Common
Status - Unconfirmed
Assigned To - 
Operating System - Unspecified / All
Severity - Low
Priority - Normal
Reported Version - SVN
Due in Version - Undecided
Due Date - Undecided
Details - There is a bug in the use of shared_ptr<>::operator->(). It attempts to use the operator to extract the underlying pointer, which is then checked. This fails because operator->() will not allow this (treats as an attempt to dereference a null pointer). A simpler check for null-pointerness is !ptr (using the conversion to unspecified-bool-type).

Also, one should use get() instead of operator->() to return the underlying pointer in other contexts (I have not made this change below, though).

Suggested fix:

--- dune/common/mpicollectivecommunication.hh	(revision 5741)
+++ dune/common/mpicollectivecommunication.hh	(working copy)
@@ -31,7 +31,7 @@
   public:
 	static MPI_Datatype get ()
 	{
-	  if (type.operator->()==0)
+	  if (!type)
 		{
 		  type = shared_ptr<MPI_Datatype>(new MPI_Datatype);
 		  MPI_Type_contiguous(sizeof(T),MPI_BYTE,type.operator->());
@@ -85,7 +85,7 @@
   public:
 	static MPI_Op get ()
 	{
-	  if (op.operator->()==0)
+	  if (!op)
 		{
 		  op = shared_ptr<MPI_Op>(new MPI_Op);
 		  MPI_Op_create((void (*)(void*, void*, int*, MPI_Datatype*))&operation,true,op.operator->());


More information can be found at the following URL:
http://www.dune-project.org/flyspray/index.php?do=details&task_id=682

You are receiving this message because you have requested it from the Flyspray bugtracking system.  If you did not expect this message or don't want to receive mails in future, you can change your notification settings at the URL shown above.




More information about the Dune mailing list