pointer and mut question #7694
k1attila12
started this conversation in
General
Replies: 2 comments
-
Casting between pointer types should require |
Beta Was this translation helpful? Give feedback.
0 replies
-
After this is merged, you will see this warning (which will become an error later):
Although the types are the same, the cast bypasses mutability checks. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
j:=1111
mut i := &int(&j)
unsafe {
*i =2222
}
println(i)
println(typeof(i))
println(j)
println(typeof(j))
in this small example i can modify j even it is immutable.
is it normal or bug ? (i think it is bug)
if i change this line :
mut i := &int(&j)
to
mut i := &j
compiler can't compile it (very correctly) because of "j is immutable"
thank you
Beta Was this translation helpful? Give feedback.
All reactions