CINT bug in 2.22/09 (constructors for member data)

From: Jonathan M. Gilligan (jonathan.gilligan@vanderbilt.edu)
Date: Fri Jul 16 1999 - 00:07:36 MEST


Consider the following code:

======================= begin code snippet ===================================
// file: test.cpp
static const char *default_string = "default";

class foo
{
public:
	foo();	
protected:
	const char *str;
};

foo::foo() : str(default_string)
{
	printf("foo::foo() : default_string = \"%s\", "
		   "str = \"%s\"\n",default_string,str);
	if (str == NULL)
		printf("str = NULL\n");
}

void test()
{
	foo * pFoo = new foo();
}
======================= end code snippet ===================================

Output from root 2.22/09 under WinNT 4.0 (SP5) is:

==================== Begin Root Output =======================
C:\Root>root test.cpp
  the current keyboard layout is 437
Warning in <TClass::TClass>: no dictionary for class TWinNTSystem is available
Warning in <TWinNTSystem::SetProgname>: Wrong Program path
   *******************************************
   *                                         *
   *        W E L C O M E  to  R O O T       *
   *                                         *
   *   Version   2.22/09      13 July 1999   *
   *                                         *
   *  You are welcome to visit our Web site  *
   *          http://root.cern.ch            *
   *                                         *
   *******************************************

CINT/ROOT C/C++ Interpreter version 5.14.8, Jul 4 1999
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.

Welcome to the ROOT tutorials

Type ".x demos.C" to get a toolbar from which to execute the demos

Type ".x demoshelp.C" to see the help window

root [0]
foo::foo() : default_string = "default"
str = NULL
root [1]
==================== End Root Output =======================

Somehow, the constructor for foo is improperly failing to initialize the
member variable foo::str. This breaks code that worked for many previous
releases of root/cint.

I can work around by rewriting my constructors to use assignments in the 
function body rather than calling constructors for member data items, but 
this will mean rewriting a lot of my class library. It also represents a 
significant change in the CINT behavior, so I would respectfully suggest 
that it represents a bug.

Do the warning messages at the top of the root output suggest a problem?

Regards,
Jonathan
===========================================================================
Jonathan M. Gilligan                     <jonathan.gilligan@vanderbilt.edu>
Research Assistant Professor of Physics                      (615) 343-6252
Dept. of Physics and Astronomy, Box 1807-B                    Fax: 343-7263
6823 Stevenson Center
Vanderbilt University, Nashville, TN 37235           Dep't Office: 
322-2828                   



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:35 MET