fix to _VL_VINT_TO_STRING in ./include/verilated.cpp #931
Labels
area: wrong runtime result
Issue involves an incorrect runtine result from Verilated model
resolution: fixed
Closed; fixed
Author Name: Fabrizio Ferrandi
Original Redmine Issue: 931 from https://www.veripool.org
Original Date: 2015-06-12
Dears,
there is a subtile bug in function _VL_VINT_TO_STRING that prevents the removal of trailing spaces.
The HEAD code is the following:
@void _VL_VINT_TO_STRING(int obits, char* destoutp, WDataInP sourcep) {
// See also VL_DATA_TO_STRING_NW
int lsb=obits-1;
bool start=true;
char* destp = destoutp;
for (; lsb>=0; lsb--) {
lsb = (lsb / 8) * 8; // Next digit
IData charval = (sourcep[VL_BITWORD_I(lsb)]>>VL_BITBIT_I(lsb)) & 0xff;
if (!start || charval) {
*destp++ = (charval==0)?' ':charval;
start = false; // Drop leading 0s
}
}
destp++ = '\0'; // Terminate
while (isspace((destp-1)) && destp>destoutp) *--destp = '\0'; // Drop trailing spaces
}
@
The problem is the following line just before the trailing spaces removal.
@ *destp++ = '\0'; // Terminate
@
The postincrement has to be removed otherwise isspace will not check the possible space but the null character.
Cheers,
Fabrizio
The text was updated successfully, but these errors were encountered: