Re: Strange execution behavior..

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux