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

Reduce compiler warnings when building yosys #4713

Open
ldoolitt opened this issue Nov 6, 2024 · 1 comment
Open

Reduce compiler warnings when building yosys #4713

ldoolitt opened this issue Nov 6, 2024 · 1 comment

Comments

@ldoolitt
Copy link
Contributor

ldoolitt commented Nov 6, 2024

Feature Description

Building current main-branch yosys (specifically commit 2de9f00) with g++ 12.2.0, I get 45 warnings:

  • 22 x maybe-uninitialized
  • 19 x sign-compare
  • 4 x unused-but-set-variable

I can eliminate most (18) of the maybe-uninitialized with this two-line patch.

diff --git a/kernel/drivertools.h b/kernel/drivertools.h
index 079701c35..39d4bd7a7 100644
--- a/kernel/drivertools.h
+++ b/kernel/drivertools.h
@@ -364,7 +364,7 @@ public:
 
        unsigned int hash() const
        {
-               unsigned int inner;
+               unsigned int inner = 0;
                switch (type_)
                {
                        case DriveType::NONE:
@@ -912,7 +912,7 @@ public:
 
        unsigned int hash() const
        {
-               unsigned int inner;
+               unsigned int inner = 0;
                switch (type_)
                {
                        case DriveType::NONE:

Do y'all want a pull request? Should I add a default: assert() to the two switch() statements?

@KrystalDelusion
Copy link
Member

The sign compares have been raised and should be in progress for fix. PR for this would be appreciated :) type_ is assigned DriveType::NONE by default, so there shouldn't be a need to assert on default, but it wouldn't hurt to check just in case.

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

No branches or pull requests

2 participants