How to use a reference of a pointer as a function argument?

Hello, All,
I tried to use ACLiC to complie my macro, with “.L mymacro++” in the command line, but I met with some warning. I guess it is because I used a reference of a pointer as a function argument. So I wrote a simple example and it did regenerate the same warning message. The code is as below:

int test_ref_ptr(int*& p) { (*p)++; return 0; }
Then I got “warning: dereferencing type-punned pointer will break strict-aliasing rules”. But If I use such piece of code & another main function, and compile with “gcc -f-strict-alliasing -W-strict-alliasing”, I don’t receive such warning from gcc.
Now, I have a few questions,
1, Why ACLiC and GCC behave differently?
2, What’s the solution to such a warning? Do I have to use int** as the argument to go around it temporarily?
Thanks in advance,
Bing

Try “gcc -O2”, “gcc -O3”, “g++ -O2”, “g++ -O3” …

Yes, I understand. I actually turned on this to force the strict aliasing rule when using gcc to compile it. And gcc didn’t throw such a warning, only ROOT complained about it.

Try to add “-Wstrict-aliasing=2” and “-O2” or “-O3”.
Try …
root [0] gDebug = 7;
root [1] .L test_ref_ptr.cxx++
I suspect that the problem is coming not from your “test_ref_ptr.cxx” but from the ROOT’s dictionary for it.

[quote]I suspect that the problem is coming not from your “test_ref_ptr.cxx” but from the ROOT’s dictionary for it.[/quote]That would be my guess too. To avoid this message (but also preventing access for this function from the interpreter), you can use:#ifndef __MAKECINT__ int test_ref_ptr(int*& p) { (*p)++; return 0; } #endifCheers,
Philippe.