nickg / nvc

VHDL compiler and simulator
https://www.nickg.me.uk/nvc/
GNU General Public License v3.0
636 stars 80 forks source link

Generic subprogram in package causes segfault #1027

Closed avelure closed 1 month ago

avelure commented 1 month ago

The MWE is from https://github.com/ghdl/ghdl/issues/2163 https://github.com/ghdl/ghdl/blob/master/testsuite/gna/issue2163/pkg3.vhdl

package pkg3 is
  generic (
    type atyp;
    function plus (a: atyp) return natural is <>);
  function wrap (a : atyp) return natural;
end pkg3;

package body pkg3 is
  function wrap (a : atyp) return natural is
  begin
    return plus (a);
  end wrap;
end pkg3;

entity tb_pkg3 is
end;

architecture behav of tb_pkg3 is
  function plus (a: bit_vector) return natural is
  begin
    return a'length;
  end plus;

  package my_pkg3 is new work.pkg3 generic map (atyp => bit_vector,
                                                plus => open);

  constant c : natural := my_pkg3.wrap("0101");
begin
  assert c = 4 severity failure;
end behav;
$ nvc --std=08 --messages=compact -a --psl dda0e81e2592bf1451aa9f61f8628d12e5dabed99df89220ed4d174ca9b57c8b
debug: C runtime library: C:\WINDOWS\System32\ucrtbase.dll
Assertion failed: tree_kind(value) == T_REF, file ../src/sem.c, line 5200
nickg commented 1 month ago

Same cause as #1025.