diff --git a/NEWS.md b/NEWS.md index c353154bc..f9b4bded9 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,8 @@ ## Unreleased changes - Fixed a crash when a subprogram is called with too many named arguments (from @NikLeberg) (#1091). +- Fixed a crash when a constant record aggregate has a null array + element (#1137). ## Version 1.15.0 - 2025-01-11 - `--load` is now a global option and should be placed before the `-r` diff --git a/src/jit/jit-interp.c b/src/jit/jit-interp.c index 456c0d6b0..8e873f52f 100644 --- a/src/jit/jit-interp.c +++ b/src/jit/jit-interp.c @@ -141,6 +141,7 @@ static inline int64_t interp_get_int(jit_interp_t *state, jit_value_t value) return state->regs[value.reg].integer; case JIT_VALUE_INT64: case JIT_VALUE_DOUBLE: + case JIT_ADDR_ABS: return value.int64; default: CANNOT_HANDLE(value); diff --git a/src/jit/jit-irgen.c b/src/jit/jit-irgen.c index d0023ccf6..ce5db50aa 100644 --- a/src/jit/jit-irgen.c +++ b/src/jit/jit-irgen.c @@ -106,7 +106,7 @@ static inline jit_value_t jit_value_from_loc(const loc_t *loc) static inline jit_value_t jit_null_ptr(void) { - jit_value_t value = { .kind = JIT_VALUE_INT64, .int64 = 0 }; + jit_value_t value = { .kind = JIT_ADDR_ABS, .int64 = 0 }; return value; } @@ -1068,6 +1068,11 @@ static void irgen_copy_const(jit_irgen_t *g, unsigned char *p, memcpy(p, g->func->cpool + value.int64, bytes); break; + case JIT_ADDR_ABS: + assert(value.int64 == 0); + assert(bytes == 0); + break; + default: fatal_trace("cannot handle value kind %d", value.kind); } diff --git a/test/regress/issue1137.vhd b/test/regress/issue1137.vhd new file mode 100644 index 000000000..51a694f41 --- /dev/null +++ b/test/regress/issue1137.vhd @@ -0,0 +1,32 @@ +entity issue1137 is +end entity; + +architecture test of issue1137 is + type t_rec is record + x : integer; + y : bit_vector(1 to 0); -- Null + z : integer; + end record; + + signal s : t_rec := (42, "", 55); +begin + + process is + variable v : t_rec := (666, "", 12); + begin + assert s.x = 42; + assert s.y = ""; + assert s.z = 55; + v.y := ""; + s.y <= ""; + wait for 1 ns; + assert s.x = 42; + assert s.y = v.y; + assert s.z = 55; + assert v.x = 666; + assert v.y = ""; + assert v.z = 12; + wait; + end process; + +end architecture; diff --git a/test/regress/testlist.txt b/test/regress/testlist.txt index d2d43e161..183e86ec5 100644 --- a/test/regress/testlist.txt +++ b/test/regress/testlist.txt @@ -1092,3 +1092,4 @@ ename17 fail,gold,2008 cmdline13 shell issue1117 normal,psl,2008 issue1125 normal,2008 +issue1137 normal