[ROOT] error from ROOT when using static const class member

From: ly1@indiana.edu
Date: Fri Feb 27 2004 - 07:14:09 MET


the program test.h and test.C can be compiled and run 
under g++ in linux. 
also can be compiled in ROOT using .L test.C++
but when I execute it, ROOT gave me a lot of error,
Is there anyone can help me with this?

Thank you in advance!


Here are the source code and error message from ROOT

/********************************
 * test.h
 *
 ********************************/

#include <iostream>

class X
{
 public:
  static const int i;
  static const int a[];

  void print();
};

const int X::a[]={0,1,2,3,4,5,6,7,8,9};
 
void X::print()
{
    std::cout << "Print static const int member:\n"
              << X::a[0] << '\t'
              << X::a[1] << '\t'
              << std::endl;
}

/*****************************************
 * test.C
 *
 *****************************************/
//#include <iostream>
#include "test.h"

using namespace std;

int main()
{
  cout << "Hello World!\n";

  X x;
  x.print();
}

/****************************************
 * error messages from ROOT
 ****************************************/
root [0] .L test.C
root [1] X x;
root [2] x.print()
Print static const int member:
 
 *** Break *** segmentation violation
 Generating stack trace...
 0x410272b8 in <unknown> from /lib/libc.so.6
 0x406077ec in G__getitem + 0x712 from /usr/local/root/lib/libCint.so
 0x40600c60 in G__getexpr + 0x3c97 from /usr/local/root/lib/libCint.so
 0x406619fa in G__exec_statement + 0x1d02 from /usr/local/root/lib/libCint.so
 0x406333ca in G__interpret_func + 0x20f5 from /usr/local/root/lib/libCint.so
 0x40610d15 in G__getfunction + 0x15cf from /usr/local/root/lib/libCint.so
 0x406a689f in G__getstructmem + 0xa5d from /usr/local/root/lib/libCint.so
 0x406a007b in G__getvariable + 0x5db from /usr/local/root/lib/libCint.so
 0x406077ec in G__getitem + 0x712 from /usr/local/root/lib/libCint.so
 0x4060603e in G__getexpr + 0x9075 from /usr/local/root/lib/libCint.so
 0x4065adca in G__exec_function + 0x1ed from /usr/local/root/lib/libCint.so
 0x406621ef in G__exec_statement + 0x24f7 from /usr/local/root/lib/libCint.so
 0x405ec77f in G__exec_tempfile_core + 0x345 from /usr/local/root/lib/libCint.so 0x405ec9e3 in G__exec_tempfile_fp + 0x31 from /usr/local/root/lib/libCint.so
 0x4066aa6c in G__process_cmd + 0x4c79 from /usr/local/root/lib/libCint.so
 0x40163b90 in TCint::ProcessLine(char const*, TInterpreter::EErrorCode*) + 0xaa from /usr/local/root/lib/libCore.so
 0x400e21f4 in TApplication::ProcessLine(char const*, bool, int*) + 0x5b6 from /usr/local/root/lib/libCore.so
 0x40e8615a in TRint::HandleTermInput() + 0x1f8 from /usr/local/root/lib/libRint.so
 0x40e84e19 in TTermInputHandler::Notify() + 0x27 from /usr/local/root/lib/libRint.so
 0x40e86a28 in TTermInputHandler::ReadNotify() + 0x14 from /usr/local/root/lib/libRint.so
 0x401c9a67 in TUnixSystem::CheckDescriptors() + 0xf7 from /usr/local/root/lib/libCore.so
 0x401c914b in TUnixSystem::DispatchOneEvent(bool) + 0xf7 from /usr/local/root/lib/libCore.so
 0x40132f6d in TSystem::InnerLoop() + 0x25 from /usr/local/root/lib/libCore.so
 0x40132efb in TSystem::Run() + 0x7d from /usr/local/root/lib/libCore.so
 0x400e2bf0 in TApplication::Run(bool) + 0x30 from /usr/local/root/lib/libCore.so
 0x40e85bf2 in TRint::Run(bool) + 0x318 from /usr/local/root/lib/libRint.so
 0x08048888 in main + 0x90 from /usr/local/root/bin/root.exe
 0x4101390b in __libc_start_main + 0xcb from /lib/libc.so.6
 0x08048761 in _Unwind_Resume + 0x31 from /usr/local/root/bin/root.exe
Root > Function print() busy flag cleared
 
root [3]

//=================== end ======================================


        Lingyun Yang
        yzine@etang.com
          2004-02-27



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:06 MET