You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the auto keyword is used in the interpreter to substitute pointer types, the value of the pointer is not printed out correctly, even though the pointer points to the correct variable.
A few simple interpreter commands to reproduce the problem:
root [0] int x = 1
(int) 1
root [1] int y = 2
(int) 2
root [2] auto xp = &x
(int *) @0x7ffe114d3bb8 <- WRONG!
root [3] auto yp = &y
(int *) @0x7ffe114d3bb8 <- WRONG!
root [4] &x
(int *) 0x7f3bcb682018
root [5] &y
(int *) 0x7f3bcb68201c
root [6] xp
(int *) @0x7ffe114d3bb8 <- WRONG!
root [7] yp
(int *) @0x7ffe114d3bb8 <- WRONG!
root [8] *xp
(int) 1
root [9] *yp
(int) 2
However, if one uses auto * instead of auto, one gets the expected behavior:
root [0] int x = 1
(int) 1
root [1] int y = 2
(int) 2
root [2] auto * xp = &x
(int *) 0x7f8f0a394018 <- CORRECT!
root [3] auto * yp = &y
(int *) 0x7f8f0a39401c <- CORRECT!
root [4] &x
(int *) 0x7f8f0a394018
root [5] &y
(int *) 0x7f8f0a39401c
root [6] xp
(int *) 0x7f8f0a394018 <- CORRECT!
root [7] yp
(int *) 0x7f8f0a39401c <- CORRECT!
root [8] *xp
(int) 1
root [9] *yp
(int) 2
Can we fix the interpreter such that it also prints the correct pointer values when auto is used?
guitargeek
changed the title
Interpreter prints wrong pointer value when auto is used
Interpreter prints wrong pointer values when auto is used
Aug 5, 2021
guitargeek
changed the title
Interpreter prints wrong pointer values when auto is used
Interpreter prints unexpected values when auto is used
Aug 5, 2021
guitargeek
changed the title
Interpreter prints unexpected values when auto is used
Interpreter prints unexpected values when auto is used for pointer types
Aug 5, 2021
I tried out if this issue is still relevant, and I can still reproduce it with ROOT 6.26. However, in ROOT master it's gone! I'll close the issue and mark it as fixed in 6.28.
When the
auto
keyword is used in the interpreter to substitute pointer types, the value of the pointer is not printed out correctly, even though the pointer points to the correct variable.A few simple interpreter commands to reproduce the problem:
However, if one uses
auto *
instead of auto, one gets the expected behavior:Can we fix the interpreter such that it also prints the correct pointer values when
auto
is used?This problem was originally spotted on the ROOT forum:
https://root-forum.cern.ch/t/wrong-object-returned-in-root-when-using-auto-keyword
The text was updated successfully, but these errors were encountered: