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

initialization only inits first 2 bytes #39

Open
youbitchoc opened this issue Aug 11, 2024 · 1 comment
Open

initialization only inits first 2 bytes #39

youbitchoc opened this issue Aug 11, 2024 · 1 comment

Comments

@youbitchoc
Copy link

initialization uses store to load the initial value, but store only loads the first two bytes, so the rest of the struct is left uninitialized.

typedef struct {
	char a, b;
	int c;
} Ty2;

Ty2 foo = { 1, 2, 3 }; // only initializes a and b (first two bytes), c left uninitialized
Ty2 bar; bar = { 4, 5, 6 }; // assignment works though

just documenting this here in case i forget to circle back to it, ideas for deduplicating assign/store stuff greatly appreciated

@youbitchoc youbitchoc changed the title struct initialization only inits first 2 bytes initialization only inits first 2 bytes Aug 15, 2024
@youbitchoc
Copy link
Author

youbitchoc commented Aug 15, 2024

same problem with arrays :(

EDIT: nvm, {0,0,...} works but i had expected {0} to work too

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

No branches or pull requests

1 participant