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

Fixed size array failure #3201

Open
mvertes opened this issue Nov 26, 2024 · 1 comment
Open

Fixed size array failure #3201

mvertes opened this issue Nov 26, 2024 · 1 comment
Assignees
Labels
🐞 bug Something isn't working in focus Core team is prioritizing this work 📦 🤖 gnovm Issues or PRs gnovm related

Comments

@mvertes
Copy link
Contributor

mvertes commented Nov 26, 2024

The following valid Go code fails:

package main

type (
	T1 struct{ Path [12]int8 }
	T2 struct{ Path *[12]int8 }
)

var (
	t11 = &T1{}
	t21 = &T2{}
)

func main() {
	b := [12]byte{}
	t12 := &T1{}
	t22 := &T2{}
	b11 := (*[len(t11.Path)]byte)(&b)
	b12 := (*[len(t12.Path)]byte)(&b)
	b21 := (*[len(t21.Path)]byte)(&b)
	b22 := (*[len(t22.Path)]byte)(&b)
	println(len(b11), len(b12), len(b21), len(b22))
}

// Output:
// 12 12 12 12
@petar-dambovaliev
Copy link
Contributor

This is not just a problem with arrays. The code that resolves constant expressions doesn't handle this at all.
This code panics the same way as your example.

const A = len(t11.Path)

@Kouteki Kouteki moved this from Backlog to Todo in 🧙‍♂️gno.land core team Nov 27, 2024
@Kouteki Kouteki added the in focus Core team is prioritizing this work label Nov 27, 2024
@Kouteki Kouteki moved this from Todo to In Progress in 🧙‍♂️gno.land core team Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working in focus Core team is prioritizing this work 📦 🤖 gnovm Issues or PRs gnovm related
Projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

3 participants