-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
v_sprintf bug? #23767
Comments
Connected to Huly®: V_0.6-22181 |
but this works correctly
Shouldn't these be the same, unless it processes them differently? |
So |
This worked for me: import strconv
struct Foo {
mut:
x u8
}
fn main() {
mut fc := Foo{u8(1)}
println(fc.x) // 1
x := int(fc.x)
s := unsafe { strconv.v_sprintf("x=%02d\n", voidptr(&x)) }
print(s) // x=01
} |
this doesn't which should be the same thing.
Can't run code. The server returned an error:
/tmp/v_60000/../../../../../../box/code.v:10: error: lvalue expected I should point out that |
I think the problem are import strconv
struct Foo {
mut:
x u8
}
fn main() {
mut fc := Foo{u8(1)}
x := u32(fc.x) // new space big enough here
s := strconv.v_sprintf("x=%02d", x)
println(s)
} variables like |
int is i32, not u32, and only until the change, but for now, at least both i32 and u32 take the same amount of space. |
What i32 and u32 at some point will not use the same space! Also more of v_sprintf:
it says its unsafe. So I assumed to use it in an unsafe block! |
i32 and u32 will. int and i32 won't. The plan is to change int so that it acts like int in Go - it will be i32 on 32-bit systems, i64 on 64-bit systems. |
V version: V 0.4.9 af3f6c1, press to see full `v doctor` output
What did you do?
./v -g -o vdbg cmd/v && ./vdbg src/main.v && src/main
What did you see?
What did you expect to see?
Note
You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.
The text was updated successfully, but these errors were encountered: