64 bit to 32 bit integer conversion on a Mac

I am having the following problem with integer types (running v. 4.04/02, CINT/ROOT v. 5.15.169 on Mac OSX 10.4.2):

I have a variable “measure” initialized as Long64_t and set with

measure = Chain.GetEntries();

When i try to use this variable in a “for” loop, as with:

 for (Int_t bicounter = 0; bicounter < measure; bicounter++) {

the loop is not run (appears “measure” is taken to be 0?). Changing “measure” to 32 bit:

  for (Int_t bicounter = 0; bicounter < Int_t(measure); bicounter++) {

then executes the loop, but gives a “conversion from 64 bit to 32 bit error”, as Chain.GetEntries() returns a 64 bit value. Similarly “if” statements don’t seem to evaluate Long64_t variables properly either. I am new to this and trying to run code that is new to me, so i appreciate any help!

Please quote which version you are running.
In case you are using a version of ROOT older than 4.04/02, upgrade
your system to a newer version.


[quote=“brun”]Please quote which version you are running.

I am running version 4.04/02, installed with Fink on OS X 10.4… i haven’t tried upgrading to 5.0, but can if recommended.

I cannot reproduce your problem with version 4.04.
Could you send a short running script showing it?


I’ve attached an example of the code that seems to give problems. It is copied below:

[code]void broken_example(){

Int_t i = 0;
Int_t x = 0;
Int_t y = 0;
Long64_t k = 3;

//These first 2 “for” statements work:

for (i; i < 2; i++){
	cout<<"i is: "<<i<<endl;

for ( Int_t j = 0; j < 2; j++){
	cout<<"j is: "<<j<<endl;

//This “for” statement does not repeat at all:

for (x; x < k; x++){
	cout<<"x is: "<<x<<endl;

//This yeild the warning “64bit to 32bit conversion” but then loops properly:

for (y; y < Int_t(k); y++){
	cout<<"y is: "<<y<<endl;

//This loops indefiniately:

// for (k = 0; k < 2; k++){
// cout<<"k is: "<<k<<endl;
// }


The output of this code is:

root [2] .x broken_example.c i is: 0 i is: 1 j is: 0 j is: 1 x is: 0 Warning: conversion from 64bit to 32bit integer FILE:broken_example.c LINE:34 y is: 0 y is: 1 y is: 2

Hope this sheds some light, thank you!
broken_example.c (773 Bytes)


Many problem with 64 bits int has been fixed since ROOT 4/04.
I just tried your example on MacOS with the latest version of ROOT (from CVS but ROOT 5/04 should be similar) and sucessfully run.

So I recommend that you upgrade to a least ROOT 5.04/00