Re: [ROOT] zero pointers on NT

From: Andre Holzner (Andre.Holzner@cern.ch)
Date: Thu Jan 25 2001 - 14:15:20 MET


Hi,


Anton Fokin wrote:
> 
> Hi rooters,
> 
> I am a bit confused with pointer initialization on win32 and VC6.0.
> 
> C++ standard says it guarantees that you get zero pointer when you define a
> pointer. 

As far as I know, I doesn't:

#include <iostream>

void main()
{
  int *x;
  cout << x << endl;
  
  x = NULL;
  cout << x << endl;

}

this program indeed produces the following output:

0xbfffeab8
(nil)

So x is essentially random before the first assignment.
The same holds for other simple data types like int.
Only for classes, one of the constructors is called upon declaration
of the variable.


best regards,


Andre


-- 
------------------+----------------------------------
Andre Holzner     | +41 22 76 76750 
Bureau 32 2-C13   | Building 32     
CERN              | Office 2-C13    
CH-1211 Geneve 23 | http://wwweth.cern.ch/~holzner/



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:34 MET