commit ed0d394707763dd7f00c5921640338eb44ef685f
parent d00a7b6007503bb9686d4692db5020b39c4cc9bd
Author: Drew DeVault <sir@cmpwn.com>
Date: Fri, 1 Jan 2021 13:51:44 -0500
Add string alignment test (and fix related bug)
Diffstat:
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/gen.c b/src/gen.c
@@ -200,8 +200,7 @@ gen_store(struct gen_context *ctx,
// TODO: Revisit me (again)
if (src->type->stype == Q__AGGREGATE) {
- if (src->indirect) {
- assert(dest->indirect);
+ if (src->indirect && dest->indirect) {
pushi(ctx->current, NULL, Q_STOREL, src, dest, NULL); // XXX: ARCH
} else if (!dest->indirect && dest->type->stype == Q__AGGREGATE) {
gen_copy(ctx, dest, src);
diff --git a/tests/04-strings.ha b/tests/04-strings.ha
@@ -1,6 +1,9 @@
fn measurements() void = {
- let x = "Hello!";
+ const x = "Hello!";
assert(len(x) == 6z);
+ assert(size(str) == size(*u8) + size(size) * 2z);
+ const align: size = if (size(*u8) > size(size)) size(*u8) else size(size);
+ assert(&x: uintptr: size % align == 0z);
};
fn charptr() void = {