Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-Wsign-compare warning in verilated.cpp #1437

Closed
veripoolbot opened this issue May 14, 2019 · 2 comments
Closed

-Wsign-compare warning in verilated.cpp #1437

veripoolbot opened this issue May 14, 2019 · 2 comments

Comments

@veripoolbot
Copy link
Contributor

@veripoolbot veripoolbot commented May 14, 2019


Author Name: Sergey Kvachonok (@ravenexp)
Original Redmine Issue: 1437 from https://www.veripool.org

Original Assignee: Sergey Kvachonok (@ravenexp)


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.

@veripoolbot
Copy link
Contributor Author

@veripoolbot veripoolbot commented May 14, 2019


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2019-05-14T10:35:37Z


Well done, thanks for the good work.

Fixed in git towards 4.016.

@veripoolbot
Copy link
Contributor Author

@veripoolbot veripoolbot commented Jun 16, 2019


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2019-06-16T13:58:37Z


In 4.016.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.