Fix crash with internal assertion on short array initializer (partial #5511)

This commit is contained in:
Wilson Snyder 2024-10-10 07:20:44 -04:00
parent f98637e122
commit 69ac3c14e8
4 changed files with 39 additions and 1 deletions

View File

@ -82,7 +82,9 @@ protected:
for (uint64_t n = 0; n < size; ++n) {
m_unpackedWord = n;
if (n) puts((n % tabMod) ? ", " : ",\n");
iterateConst(nodep->getIndexDefaultedValuep(n));
AstNode* const itemp = nodep->getIndexDefaultedValuep(n);
UASSERT_OBJ(itemp, nodep, "Missing array init element");
iterateConst(itemp);
}
puts("\n");
puts("}");

View File

@ -0,0 +1,4 @@
%Error: Internal Error: t/t_unpacked_concat_bad3.v:9:41: ../V3EmitCConstInit.h:#: Missing array init element
9 | localparam logic [7:0] TOO_FEW [5] = '{0, 1, 2**8-1};
| ^~
... See the manual at https://verilator.org/verilator_doc.html for more assistance.

View File

@ -0,0 +1,17 @@
#!/usr/bin/env python3
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2024 by Wilson Snyder. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
import vltest_bootstrap
test.scenarios('vlt')
# Not lint, crashes in V3EmitCConstInit.h
test.compile(fails=True, expect_filename=test.golden_filename)
test.passes()

View File

@ -0,0 +1,15 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed into the Public Domain, for any use,
// without warranty, 2019 by Driss Hafdi.
// SPDX-License-Identifier: CC0-1.0
module t (/*AUTOARG*/);
localparam logic [7:0] TOO_FEW [5] = '{0, 1, 2**8-1}; // Bad
initial begin
$display("%p", TOO_FEW);
$stop;
end
endmodule