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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion ir/json_generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.

case TOP:
case VEC_START:
case VEC_MID:
case OBJ_AFTERTAG:
BUG("invalid json output state in end_object");
break;
}
Expand Down
Loading