-
Notifications
You must be signed in to change notification settings - Fork 670
Fix crash when comparing queue to scalar (#5570) #5950
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 10000 to your account
Conversation
…6/verilator into bugfix/queue-compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work, appreciate the fix.
Thanks for updating. Can you please merge master, resolve conflicts. Then in GitHub hit "resolve conversation" for each of the items you think are fixed. I'll then re-review. |
…6/verilator into bugfix/queue-compare
I've cleaned up the coding style a bit and added more test cases to cover additional scenarios. One thing I wanted to mention is, while I initially tried to use That made me realize there's a more fundamental issue. Verilog doesn't really define a concept like similar types. What it defines are type compatibility rules like matching types (LRM 6.22.1), equivalent types (LRM 6.22.2), assignment-compatible types (LRM 6.22.3), and others. In this case, comparisons of aggregate data types should be based on equivalent types. So for now, I've added an equivalent types check specifically for aggregate data type comparisons to address this bug. There might be a need for a broader refactor in the future to fully align with Verilog's type compatibility rules, but at this point I'm focusing on fixing the immediate issues. |
Fixed |
Thanks! There's a pile of issues with very similar lint-rule-missing cases, it would be excellent if you'd consider making pulls for one/some of those too. (It's also possible this fixed pull already fixes some of them). |
Summary
Fixes #5570.
This PR adds proper validation to reject comparisons between incompatible aggregate types (e.g. queue vs scalar). Previously, Verilator would generate invalid C++ code and crash during compilation, making it hard to debug.
What changed
areAggregatesComparable
to recursively verify that aggregate types are structurally comparable.visit_cmp_eq_gt
to call this check and emit an early error with useful context.expandBiOp
. With the new validation, those conditions can no longer be hit.Notes
This is my first PR. If there are better conventions or places this logic should live, I’m open to feedback. Appreciate any suggestions to improve this!