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 · 3 comments · May be fixed by #3600
Open

Fixed size array failure #3201

mvertes opened this issue Nov 26, 2024 · 3 comments · May be fixed by #3600
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)

@thehowl
Copy link
Member

thehowl commented Jan 16, 2025

The code in OP is still failing on master. @omarsy, do you want to take a look at it?

@omarsy
Copy link
Member

omarsy commented Jan 16, 2025

yes I can have a look on this

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
5 participants