[cling] void macro should not return value
Describe the bug
void test() { return 1; }
Interpreting this snippet with cling does not raise errors. Compiling with AcLiC .C+ generates an error. error: void function 'test' should not return a value [-Wreturn-type]
Expected behavior
Interpreting should at least raise a warning?
To Reproduce
root -l test.C
vs
root -l test.C+
or copy-paste the function in the ROOT terminal and call test().
Setup
------------------------------------------------------------------
| Welcome to ROOT 6.27/01 https://root.cern |
| (c) 1995-2022, The ROOT Team; conception: R. Brun, F. Rademakers |
| Built for linuxx8664gcc on Apr 25 2022, 22:21:18 |
| From heads/master@v6-25-01-3897-gf39eb0e984 |
| With c++ (Ubuntu 8.4.0-1ubuntu1~18.04) 8.4.0 |
| Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q' |
------------------------------------------------------------------
Additional context
Since I always teach my students to use "root -l myscript.c+", @Axel-Naumann asked me once for one example where compiling the code gave me more useful info when error appears than just interpreting, in order to find your own silly bugs when you write code. At that moment, I couldn't find a good example, it was more about past experience I had in the back of the mind, but this could be one (not specially relevant) case ;)
(Maybe it's not exactly about cling, but rather to the fact that the compilation enables more warning flags than the 'interpret', thus making it easier to you to find your issues in the code).
root [0] .rawInput
Using raw input
root [1] void test() { return 1; }
ROOT_prompt_1:1:15: error: void function 'test' should not return a value [-Wreturn-type]
void test() { return 1; }
^ ~
So there's more to the story - cling seems to suppress this, and it's not fixed by (the otherwise still reasonable) PR https://github.com/root-project/root/pull/10911
Compiling this with ACLiC makes cling issue the above diagnostic - so cling knows very well, but doesn't report this during .x.
@jalopezg-git I think you fixed this recently, right?
@jalopezg-git I think you fixed this recently, right?
Yes, thanks for mentioning me here; thus, closing issue!