A bug in 1.0.0B1

Source code:
from std.memory import Pointer

def main():
var my_val = 100
var my_p = Pointer(to=my_val)
print(my_p)
print(*my_p)

Please submit a bug report to Issues · modular/modular · GitHub and include the crash backtrace along with all the relevant source codes.
Stack dump:
0. Program arguments: mojo test_0b.mojo

  1. Crash resolving decl body at loc(“/home/diaor/Documents/Mojo/mojo-project/test_0b.mojo”:3:5)

    def main():
    ^

  2. Crash parsing statement at loc(“/home/diaor/Documents/Mojo/mojo-project/test_0b.mojo”:8:5)

    print(*my_p)
    
       ^           
    
  3. Crash ParamInf::inferForCall at loc(“/home/diaor/Documents/Mojo/mojo-project/test_0b.mojo”:8:5)

    print(*my_p)
    
       ^           
    

[826545:826546:20260604,172643.799882:ERROR directory_reader_posix.cc:42] opendir /home/diaor/Documents/Mojo/life/.pixi/envs/default/share/max/crashdb/attachments/84bfce90-37d9-499e-becd-d271814d3098: No such file or directory (2)
#0 0x000056377eb766ab (/home/diaor/Documents/Mojo/life/.pixi/envs/default/bin/mojo+0x80926ab)
#1 0x000056377eb737ca (/home/diaor/Documents/Mojo/life/.pixi/envs/default/bin/mojo+0x808f7ca)
#2 0x000056377eb772f7 (/home/diaor/Documents/Mojo/life/.pixi/envs/default/bin/mojo+0x80932f7)
#3 0x00007fa84293d520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007fa842a1990d syscall ./misc/../sysdeps/unix/sysv/linux/x86_64/syscall.S:38:0
#5 0x00007fa842c23a23 (/home/diaor/Documents/Mojo/life/.pixi/envs/default/bin/../lib/libAsyncRTMojoBindings.so+0xd2a23)
#6 0x00007fa84293d520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#7 0x000056378dd3bdd0
Segmentation fault

Looks like you want to deref the pointer with print(*my_p). The correct deref syntax is with [] so

def main():
    var my_val = 100
    var my_p = Pointer(to=my_val)
    print(my_p)
    print(my_p[])

which will result in something like

0x16d46c3a8
100

Please check the mojo manual to learn the basics and the forum is markdown friendly. For discovered bugs, please create issues in the github.

Thanks for reporting this; the compiler definitely shouldn’t crash on this input.

Luckily I believe this bug has already been fixed in our nightly. I just tried running it and got:

/examples/pointer.mojo:7:12: error: invalid call to 'print': cannot unpack value of type 'Pointer[Int, origin_of(my_val)]' into a variadic pack argument; expected a VariadicPack
    print(*my_p)
    ~~~~~  ^
oss/modular/mojo/stdlib/std/io/io.mojo:376:5: note: function declared here
def print[
    ^

If you like, switch to the most recent nightly build now, or wait until 1.0.0B2 is released.