New to cling: should I report this as a bug?

Hello. I am new to Cling. I downloaded and compiled Cling using the build script at root.cern.ch/drupal/content/clin … structions. Currently the src/ directory created by the above script is at 88c56cd6d6aec0c44e9ca5aa96b354c1261a95aa. Please note the following transcript:

$ ./inst/bin/cling 

****************** CLING ******************
* Type C++ code and press enter to run it *
*             Type .q to exit             *
*******************************************
[cling]$ # include <stdio.h>
[cling]$ for ( int j = 0 ; j < 3 ; ++j ) printf("%d\n", j) ;
0
1
2
[cling]$ for ( int j = 0 ; j < 3 ; ++j )
[cling]$ printf("%d\n", j) ;
input_line_7:2:17: error: use of undeclared identifier 'j'
 printf("%d\n", j) ;
                ^
[cling]$ 

Is this a known bug? Or should I report it? Thanks.

This is not a bug. It should behave like that, “j” is unknown at the 2nd printf time. You need { and } :

root [0] for ( int j = 0 ; j < 3 ; ++j ) printf("%d\n", j) ;
0
1
2
root [1] for ( int j = 0 ; j < 3 ; ++j )
root [2] printf("%d\n", j) ;
input_line_43:2:18: error: use of undeclared identifier 'j'
 (printf("%d\n", j))
                 ^
root [3] for ( int j = 0 ; j < 3 ; ++j ) {
root (cont'ed, cancel with .@) [4] printf("%d\n", j) ;
root (cont'ed, cancel with .@) [5]}
0
1
2
root [6] 

Hello, but in standard C++ I don’t need the braces. Are you saying that in Cling due to the limitations if I need to continue a statement block I should terminate the first line by } so it will wait for the { before parsing? Is there documentation anywhere that says so? (I did google for it but might have missed something.)

Note that [quote=“Cling - ROOT”]Cling is capable to parse everything that Clang can do.[/quote] and Clang can certainly compile it whether the printf is on a separate line or the same…

Same problem here: Cling & CINT parse issue?

Thanks,

I have submitted a lengthy :slight_smile: post on the other thread Cling & CINT parse issue? - let’s just continue there, please.

Axel.