Skip to content

Commit

Permalink
Fix crash dumping subtype that cannot be represented in FST
Browse files Browse the repository at this point in the history
Issue #840
  • Loading branch information
nickg committed Jan 28, 2024
1 parent 0101f91 commit ad6fb27
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 3 deletions.
3 changes: 1 addition & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
correctly in VHDL-2008 mode (#826).
- Fixed a memory corruption bug when evaluating certain aggregates that
contain a range association (#827).
- Fixed a crash when using the `'subtype` attribute with a constrained
port declaration (#837).
- Resolved several other minor issues (#837, #839, #840).

## Version 1.11.2 - 2024-01-04
- Fixed an incorrect length check in the equivalent process for
Expand Down
6 changes: 5 additions & 1 deletion src/rt/wave.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,11 @@ static fst_type_t *fst_type_for(type_t type, const loc_t *loc)
switch (type_kind(type)) {
case T_SUBTYPE:
{
*ft = *fst_type_for(type_base(type), loc);
fst_type_t *baseft = fst_type_for(type_base(type), loc);
if (baseft == NULL)
goto poison;

*ft = *baseft;

switch (is_well_known(type_ident(type))) {
case W_STD_NATURAL: ft->sdt = FST_SDT_VHDL_NATURAL; break;
Expand Down
2 changes: 2 additions & 0 deletions test/regress/gold/issue840.dump
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#0 issue840.t 00000000000000000000000000000001
#1000000 issue840.t 00000000000000000000000000000010
23 changes: 23 additions & 0 deletions test/regress/issue840.vhd
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
entity issue840 is
end entity;

architecture test of issue840 is
type t_array2d is array (natural range <>, natural range <>) of bit;
subtype t_sub is t_array2d(1 to 3, 1 to 3);

signal s : t_sub;
signal t : integer;
begin

process is
begin
s <= ("101", "110", "111");
t <= 1;
wait for 1 ns;
s <= ("110", "000", "101");
t <= 2;
wait for 1 ns;
wait;
end process;

end architecture;
1 change: 1 addition & 0 deletions test/regress/testlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -918,3 +918,4 @@ issue825 normal
issue826 normal,2008
issue827 normal,2008
issue839 normal
issue840 wave

0 comments on commit ad6fb27

Please sign in to comment.