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

cgen: fix cast in the index of reference fixed array (fix #13128) #13131

Merged
merged 2 commits into from
Jan 11, 2022

Conversation

yuyi98
Copy link
Member

@yuyi98 yuyi98 commented Jan 11, 2022

This PR fix cast in the index of reference fixed array (fix #13128).

  • Fix cast in the index of reference fixed array.
  • Add test.
type Entity = int

struct Component {
	vals [256]int
}

fn (c Component) get_broken(e Entity) &int {
	return &c.vals[int(e)]
}

fn main() {
	c := Component{}
	a := c.get_broken(Entity(10))
	println(*a)
	assert *a == 0
}

PS D:\Test\v\tt1> v run .
0

@spytheman spytheman merged commit 1e52b2c into vlang:master Jan 11, 2022
spytheman added a commit to jeffmikels/v that referenced this pull request Jan 11, 2022
* origin:
  ci: vfmt fmt.v ...
  cgen: fix `$if T.typ is Type {` (vlang#13135)
  parser: add support for mutable if guards (vlang#13132)
  tests: test with valgrind rune.bytes(), fix leak in .str_escaped()
  builtin: reduce allocations in `rune.bytes()`
  builtin: allow msvc users to link against a custom compiled Boehm library (vlang#13133)
  cgen: fix cast in the index of reference fixed array (fix vlang#13128) (vlang#13131)
  builtin: add a rune.bytes() convenience method (vlang#13129)
  checker: check error for match conditions with parenthesis (vlang#13130)
@yuyi98 yuyi98 deleted the fix_fixed_array_index branch January 11, 2022 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

C error when casting index and returning a pointer on a fixed length array
2 participants