-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Description
Check duplicate issues.
- Checked for duplicates
Description
See https://root-forum.cern.ch/t/return-from-an-unnamed-macro-in-root-6-broken/29867
Was a subpart of https://its.cern.ch/jira/browse/ROOT-4780
Return behavior was working well with ROOT 5.34 unnamed macros.
Workaround for ROOT6 is obvious, using named macros, but that prevents global variable reuse later from prompt (unless you brutally put all variable declarations outside the named macro upfront)
Reproducer
Run it via root test.cxx
{
cout << "phase 1" << endl;
return;
cout << "phase 2" << endl;
TChain c;
cout << "phase3" << endl;
cout << "end of the program" << endl;
}
You get:
phase 1
phase3
end of the program
It seems as if TChain c is kind of "restarting" the program flow (invalidating the return).
Funnily, it works fine if you copy-paste that snippet into the command prompt, and you just get as expected:
phase 1
ROOT version
ROOT v6.36.02
Built for linuxx8664gcc on Jul 08 2025, 22:08:50
From tags/v6-36-02@v6-36-02
With c++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Binary directory: /opt/root/bin
Installation method
Binary release
Operating system
Ubuntu 22.04
Additional context
Same issue with
------------------------------------------------------------------
| Welcome to ROOT 6.39.01 https://root.cern |
| (c) 1995-2025, The ROOT Team; conception: R. Brun, F. Rademakers |
| Built for linuxx8664gcc on Nov 15 2025, 17:33:58 |
| From heads/master@v6-23-01-RF-binSampling-25184-g9167c40c2a |
| With g++ (Ubuntu 11.4.0-1ubuntu1~22.04.2) 11.4.0 std201703 |
| Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q' |
------------------------------------------------------------------