Skip to content
CodeWiki
Practice
Paths
Tracks
Cheatsheets
Playground
Glossary
AI era
Search
⌘K
English
English
Chinese
Practice
Paths
Tracks
Cheatsheets
Playground
Glossary
AI era
English
English
Chinese
Practice
/
Quiz
/
C++
/
C structs, unions and enums
A protocol byte is converted to enum MessageKind. What should happen before using it to i…
from C structs, unions and enums
C23 (GCC 13.3.0)
intermediate
1 min
A protocol byte is converted to enum MessageKind. What should happen before using it to index a handler table?
Validate that it equals one of the supported enumerator values
Assume the conversion clamps it to the nearest enumerator
Check only that sizeof(MessageKind) equals one
Read it through a union to make it type-safe
Check
Ask AI about this kata
Report an error
next kata
What does this program print?
Predict the output
A new version is available
Reload