[Halld-online] Compilers for Hall D online and smart pointers

Elliott Wolin wolin at jlab.org
Thu Jun 6 09:36:54 EDT 2013


Hi,

There was a brief discussion about my statement concerning compilers at 
the collaboration meeting on Mon.  I didn't want to get into details 
then, I elaborate below.

What I was getting at was not so much the specific choice of compiler 
version, as there are many to choose from, but rather the use of certain 
features of the C++11 standard that should be very beneficial.  These 
are only available in the more recent gcc versions, such as 4.8.0, which 
is installed on the CUE system and on the HDCC.

In particular, I'm thinking about smart pointers.

Years ago studies showed that a large fraction of the bugs in C/C++ 
programs was related to pointer use (pointer arithmetic, off-by-one 
errors, memory leaks, etc).  Java was specifically designed to avoid 
these pitfalls by eliminating pointers, and there is almost universal 
agreement that this was excellent idea that worked out extremely well.

Smart pointers are C++'s answer to Java references (specifically, 
shared_ptr<>).  They go a long way towards achieving in C++ what was 
achieved in Java in terms of code reliability.  The previous C++ 
standard (1999?) almost incorporated smart pointers, but I understand 
they missed the deadline for the specification or something like that.  
Smart pointers have been thoroughly tested over the past decade and work 
reliably as designed.  Syntactically they are almost identical to bare 
pointers so it is easy to use them.

At the next online meeting I will discuss this in more detail.  I 
personally would even go so far as to say that their use should be 
default, and one should have a very good reason why they are not used in 
a particular application (legacy code and external libraries are a few 
obvious reasons).  I suspect some will disagree, which is why we need a 
discussion.

Thanks,

-- 

				Sincerely,
					Elliott


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


  Those raised in a morally relative or neutral environment will hold
		    no truths to be self-evident.
				

Elliott Wolin
Staff Physicist, Jefferson Lab
12000 Jefferson Ave
Suite 8 MS 12A1
Newport News, VA 23606
757-269-7365

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



More information about the Halld-online mailing list