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

fix warnings from -Wswitch-enum #5170

Merged
merged 1 commit into from
Mar 12, 2025
Merged

Conversation

ChrisDodd
Copy link
Contributor

No description provided.

@ChrisDodd ChrisDodd requested a review from asl March 9, 2025 05:08
@ChrisDodd ChrisDodd force-pushed the cdodd-warnings branch 2 times, most recently from d5206da to e6a9727 Compare March 9, 2025 20:41
@@ -135,7 +135,10 @@ class JSONGenerator {
break;
case OBJ_END:
break;
default:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder, should the default: still exist in case new enum value is added or somehow we get value which is not one of the enumerated once?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, adding a new switch value will trigger the -Wswitch-case warning again, regardless of whether default is present or not. Since getting a value that is not a valid tag value (from memory corruption or uninitialized data) would only be possible with undefined behavior, it is not clear what adding default would actually gain.

@fruffy fruffy added the core Topics concerning the core segments of the compiler (frontend, midend, parser) label Mar 11, 2025
@ChrisDodd ChrisDodd added this pull request to the merge queue Mar 12, 2025
Merged via the queue into p4lang:main with commit 85e17e6 Mar 12, 2025
21 checks passed
@ChrisDodd ChrisDodd deleted the cdodd-warnings branch March 12, 2025 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Topics concerning the core segments of the compiler (frontend, midend, parser)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants