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

Undriven struct members do not trigger -Wunassigned-variable #829

Open
jrudess opened this issue Sep 26, 2023 · 2 comments
Open

Undriven struct members do not trigger -Wunassigned-variable #829

jrudess opened this issue Sep 26, 2023 · 2 comments
Labels

Comments

@jrudess
Copy link
Contributor

jrudess commented Sep 26, 2023

Unsure if this is a bug report or a feature request. The warnings that check for reading unassigned variables has a small gap if that variable is a member of a struct, but this might be intentional.

In the following example, only member 's.a' is driven and 's.b' is undriven.

Top level design units:
    top

Build succeeded: 0 errors, 0 warnings
typedef struct {
    logic a;
    logic b;
} s_t;

module top(
    output logic x, y, z
);
    s_t s;
    always_comb s.a = 1'b1;

    always_comb begin
        if (s.b) begin
            x = 1'b1;
        end else begin
            x = 1'b0;
        end
    end

    always_comb y = s.b;

    always_comb begin
        z = s.b ? 1'b1 : 1'b0;
    end

endmodule
@MikePopoloski
Copy link
Owner

Yes, it's intentional. I can add a new warning set for struct members though.

@jrudess
Copy link
Contributor Author

jrudess commented Sep 27, 2023

I'm assuming that a full struct initialization would count as all members having a driver (s = '0). Most code is written this way, it's just the occasional one-off module where the designer uses individual assign statements for each struct member that I've hit a few cases of missed drivers. A new warning here would be great to help push finding the issue to earlier in the process.

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

No branches or pull requests

2 participants