Akuli / jou

Yet another programming language
MIT License
11 stars 4 forks source link

Change union codegen to be aligned properly #328

Closed Akuli closed 1 year ago

Akuli commented 1 year ago

~Similar to how clang works, at least according to https://stackoverflow.com/a/12757239~

The previous solution of just using i8 array won't work on platforms that need stuff to be aligned. On x86_64 you don't need to align things, so that's why it worked, but it could cause problems if I port Jou to a different platform.

I changed it to array of i64 (of appropriate size), so it is always aligned as needed. It can be larger than necessary though, if your union is very small otherwise.