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

Interpreter prints unexpected values when auto is used for pointer types #8806

Closed
1 task
guitargeek opened this issue Aug 5, 2021 · 1 comment
Closed
1 task
Assignees

Comments

@guitargeek
Copy link
Contributor

  • Checked for duplicates

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?

This problem was originally spotted on the ROOT forum:
https://root-forum.cern.ch/t/wrong-object-returned-in-root-when-using-auto-keyword

@guitargeek 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 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 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
@guitargeek
Copy link
Contributor Author

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.

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

2 participants