Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling ProcessLine in an unnamed macro leave Cling in a broken state .. sometimes #15481

Open
pcanal opened this issue May 10, 2024 · 2 comments
Assignees
Milestone

Comments

@pcanal
Copy link
Member

pcanal commented May 10, 2024

Description

In an unnamed macro having:

{
gROOT->ProcessLine(statement_1);
statement_2;
}

is process line by line (per se) and statement_2 should (and does in most case) be able to use declaration made in statement_1. In some circumstances it does not. One such circumstance is the test roottest-cling-return-constRetrunTest_WILL_FAIL which should actually succeed (the original problem is fixed by moving to Cling) but still fails (unexpectedly) with:

Processing run.C...
/Users/pcanal/root_working/code/master/roottest/cling/return/./run.C:7:1: error: unknown type name 't02'
t02 t;
^

Reproducer

With the files in trun.tar.gz
we can set that the declaration in the ProcessLine are properly seen in the next lines. For example this version of trun.C:

{
gROOT->ProcessLine(".L t1.C");
gROOT->ProcessLine(".L t2.C");
int i123 = t_1;
int j123 = t_2;
}

works fine. Note that issuing on the prompt right after the .x trun.C the command gROOT->SetDirLevel(t_1); or i123 = t_2; works as well.

But this version:

{
gROOT->ProcessLine(".L t1.C");
gROOT->ProcessLine(".L t2.C");
int i123 = t_1;
int j123 = t_2;
gROOT->SetDirLevel(t_1);
}

mysteriously fails with:

Processing trun.C...
/Users/pcanal/root_working/code/master/roottest/cling/return/./trun.C:7:1: error: cannot initialize an array element of type 'void *' with an rvalue of type 'TROOT *(*)()'
gROOT->SetDirLevel(t_1);
^~~~~
/Users/pcanal/root_working/builds/master-pr/include/TROOT.h:407:16: note: expanded from macro 'gROOT'
#define gROOT (ROOT::GetROOT())
               ^~~~~~~~~~~~~

The error seems to indicate that the parser is 'prefixing' to gROOT something related to array of void* and initialization

Similarly

{
gROOT->ProcessLine(".L t1.C");
gROOT->ProcessLine(".L t2.C");
int i123 = t_1;
int j123 = t_2;
i123 = t_2;
}

fails with:

Processing trun.C...
Assertion failed: (Node->getDependence() == ExprDependence::None), function VisitBinaryOperator, file DynamicLookup.cpp, line 628.
Abort trap: 6

And weirdly:

{
gROOT->ProcessLine(".L t1.C");
gROOT->ProcessLine(".L t2.C");
int i123 = t_1;
int j123 = t_2;
t_1 = 3;
}

fails with:

/Users/pcanal/root_working/code/master/roottest/cling/return/./trun.C:7:1: warning: declaration without the 'auto' keyword is deprecated: function '__cling_Un1Qu30' [-Wdeprecated-declarations]
t_1 = 3;
^~~
auto 
input_line_11:2:3: error: reference to 't_1' is ambiguous
 (t_1)
  ^
/Users/pcanal/root_working/code/master/roottest/cling/return/t1.C:1:5: note: candidate found by name lookup is 't_1'
int t_1 = 3;
    ^
/Users/pcanal/root_working/code/master/roottest/cling/return/./trun.C:7:1: note: candidate found by name lookup is '__cling_N50::t_1'
t_1 = 3;
^
input_line_11:2:3: error: unknown type name 't_1'
 (t_1)
  ^
@pcanal pcanal added the bug label May 10, 2024
@pcanal pcanal added this to the 6.32/00 milestone May 10, 2024
@pcanal pcanal changed the title Calling ProcessLine in an unnamed macro leave Cling in a broken state. Calling ProcessLine in an unnamed macro leave Cling in a broken state .. sometimes May 10, 2024
@hahnjo
Copy link
Member

hahnjo commented May 13, 2024

I personally don't think this should block the 6.32 release: As far as I understand, this has basically always been broken in Cling, and I verified that constRetrunTest_WILL_FAIL doesn't pass either on 6.20 using LLVM 5:

1079: Processing /home/jhahnfel/ROOT/v6-20-00-patches/src/roottest/cling/return/run.C...
1079: /home/jhahnfel/ROOT/v6-20-00-patches/src/roottest/cling/return/run.C:7:4: error: expected ';' after expression
1079: t02 t;
1079:    ^
1079:    ;
1079: /home/jhahnfel/ROOT/v6-20-00-patches/src/roottest/cling/return/run.C:7:5: error: use of undeclared identifier 't'
1079: t02 t;
1079:     ^
1079: /home/jhahnfel/ROOT/v6-20-00-patches/src/roottest/cling/return/run.C:8:15: error: use of undeclared identifier 't'
1079: TObject o = **t.getVal();
1079:               ^
1079: /home/jhahnfel/ROOT/v6-20-00-patches/src/roottest/cling/return/run.C:9:24: error: use of undeclared identifier 't'
1079: TObject * const * op = t.getVal();
1079:                        ^

@pcanal
Copy link
Member Author

pcanal commented May 13, 2024

Will_Fail is the (now) expected result and lead to a 'succesfull' run of the test. What is "new" is that there is one platform where this failure is now a segmentation fault of sort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants