This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Strange execution behavior..
- From: Andrew Haley <aph at redhat dot com>
- To: ISHWAR RATTAN <rattan at cps dot cmich dot edu>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Thu, 22 Mar 2007 19:17:05 +0000
- Subject: Re: Strange execution behavior..
- References: <Pine.GSO.4.61.0703221456260.7295@cps158.cps.cmich.edu>
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.