Project

General

Profile

[logo] 
 
Home
News
Activity
About/Contact
Major Tools
  Dinotrace
  Verilator
  Verilog-mode
  Verilog-Perl
Other Tools
  BugVise
  CovVise
  Force-Gate-Sim
  Gspice
  IPC::Locker
  Rsvn
  SVN::S4
  Voneline
  WFH
General Info
  Papers

Issue #1437

-Wsign-compare warning in verilated.cpp

Added by Sergey Kvachonok 4 months ago. Updated 3 months ago.

Status:
Closed
Priority:
Low
Category:
Configure/Make/Compiling
% Done:

0%


Description

I do not use verilated.mk to compile the generated C++ code, and I get these warnings (CFLAGS = -Wall -Wextra)

/usr/share/verilator/include/verilated.cpp:1319:41: warning: comparison of integer expressions of different signedness: ‘int’ and ‘IData’ {aka ‘unsigned int’} [-Wsign-compare]
    for (int row_addr = start; row_addr <= end; ++row_addr) {
                                ~~~~~~~~^~~~~

I've modified VL_WRITEMEM_N() to use unsigned size and offset integer types throughout and moved the address range checks out of the writing loop. I believe it is better to fail these checks as early as possible and avoid creating empty or incomplete memory dump files.

$writemem("a", a, 1, 0);

now aborts with an error message instead of creating an empty dump file.

I tested the attached patch with 'make test_regress' only, as I don't use $writemem() myself. Please review.

0001-Refactor-VL_WRITEMEM_N-address-range-checking.patch View (3.16 KB) Sergey Kvachonok, 05/14/2019 07:10 AM

History

#1 Updated by Wilson Snyder 4 months ago

  • Category changed from Usage to Configure/Make/Compiling
  • Status changed from New to Resolved
  • Assignee set to Sergey Kvachonok

Well done, thanks for the good work.

Fixed in git towards 4.016.

#2 Updated by Wilson Snyder 3 months ago

  • Status changed from Resolved to Closed

In 4.016.

Also available in: Atom