Different output depending upon array definition method

Dear Root Talk,

A colleague and I came across an interesting bug - I tried searching but couldn’t find anything however I wanted to make sure it isn’t already know or that it actually wasn’t one!

The code output depends upon how the array is declared, either in one line

bool array[5] = {true, true, true, false, false};

versus

bool array[5];
array[0] = true;
array[1] = true;
array[2] = true;
array[3] = true;
array[4] = true;

In the former case the output is modified in a non-logical way (at least to us).

This is not the case if the C++ compiler is used, so I think CINT is the culprit.

I have attached two macros. bug1.C shows how the output is modified if there is only one array while bug2.C shows what happens when there are two arrays defined. Just change the preprocessor value to flip between the two declaration methods.

Is this a bug or are we just not understand something?

Thanks,
Bertrand
bug2.C (1.05 KB)
bug1.C (1.45 KB)

which root version are you using?
I can’t reproduce any difference in output with root 5.24 5.18 and 5.12f
(your attached bug1.C has two different first_check, if you set them the same it works as expected in named versions)

I am running 5.22 on my laptop

ROOT 5.22/00 (trunk@26997, Jan 24 2009, 09:54:00 on macosx)

CINT/ROOT C/C++ Interpreter version 5.16.29, Jan 08, 2008

while on the server at BNL it is 5.12/00h-rc2

Compiled on 17 October 2007 for linux with thread support.

CINT/ROOT C/C++ Interpreter version 5.16.13, June 8, 2006

It does work for the old version (4.00/08) we have running on our departmental server

Compiled for solarisCC5.

CINT/ROOT C/C++ Interpreter version 5.15.138, May 23 2004

I have to add to the mystery. The attached macros cause the described problem on my laptop running the above mentioned version of ROOT. However, they don’t reproduce the issue on the BNL server. I thought I had run the codes on there as well, but apparently at the time I thought it was a universal ROOT problem – sorry about that, I should have check that.

This just means the macros don’t illustrate the problem which my colleague found while running on the BNL server. In the message she sent

I will try and figure out a simple macro which will cause the problem on the BNL servers as well. In the mean time it would be interesting if someone can reproduce the problem on the Mac compiled version (powerpc-apple-darwin9, gcc version 4.0.1 (Apple Inc. build 5484)).

I haven’t had a chance to write a new macro, but I did have some other Mac users try out my two codes. On PPC the strange behavior occurs while on Intel it does not.