jupyter-xeus / xeus-cling

Jupyter kernel for the C++ programming language
BSD 3-Clause "New" or "Revised" License
3.02k stars 292 forks source link

Why printing an address `&x` do not work? #475

Open AtomicVar opened 1 year ago

AtomicVar commented 1 year ago

I tried to inspect the address of an variable x with:

int x = 42;
&x

It showed:

@0x7ffc383a5a88

But if I use printf to print the address, the result is different:

printf("&x=%p\n", &x)

It showed:

&x=0x7f69a0a6c0e0

If you create another int y and print its address with &y, it' the same with &x!

int y = 99;
&y

It showed:

@0x7ffc383a5a88

Seems like printing an address with &x is not working. Why?

JohanMabille commented 1 year ago

Thanks for reporting. I think we are missing an overload of mime renderer for pointers, and thus it print the address of an internal object.