This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Strange execution behavior..


ISHWAR RATTAN writes:
 > I was asked by a colleague about the code given below.
 > I compiles and runs as:
 >   1. No errors on: AMD64 based Solaris-10 (g++: 3.4.3)
 >   2. Buserror on SPARC based Solaris-10 (g++: 3.4.4)
 >      after printing the results..
 >   3. Segmentation fault on Linux (g++: 4.1.2) after
 >      printing the results..
 > 
 > Any pointers will be appreciated.

Your default constructor is broken.


 > template<class T>
 > smartPtr<T>::smartPtr()
 > // default constructor
 > {
 >    *p = T();
 > }

What does p point to?

Andrew.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]