harec

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 9a3c054915fd941de324a94cdd60325eccdae561
parent deb68cd3612201987dad8f19e752b3f2ad0c3426
Author: Karl Schultheisz <k@kdsch.org>
Date:   Fri, 15 Apr 2022 14:53:38 -0400

types: use promotion algo to cast flexible consts

Fix a segfault in the type checker for incorrect code such as

	let a: [0xf1a97acc: [0]int]int;

for which Valgrind amusingly reports

	Address 0xf1a97acc is not stack'd, malloc'd or (recently) free'd

by using the promotion algorithm to determine castability of
flexible constants.

See spec commit be14631dfb548a1eebc871eb55e7aca4d9f4f7a0,
sections 6.6.26.7 and 6.10.

Signed-off-by: Karl Schultheisz <k@kdsch.org>

Diffstat:
Msrc/types.c | 2+-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/types.c b/src/types.c @@ -918,7 +918,7 @@ type_is_castable(const struct type *to, const struct type *from) case STORAGE_FCONST: case STORAGE_ICONST: case STORAGE_RCONST: - return lower_const(from_orig, to_orig); + return promote_const(from_orig, to_orig); case STORAGE_I8: case STORAGE_I16: case STORAGE_I32: