CppCoreGuidelines icon indicating copy to clipboard operation
CppCoreGuidelines copied to clipboard

ES.79 is a terrible advice and should be dropped

Open hasselmm opened this issue 6 months ago • 7 comments

ES.79 is a terrible advice that will cause unreliably code and serious bugs once project evolve and new enum values get added. Adding a default case to switch statements blinds compilers regarding new enum values (unless the proper compiler with the proper magic switches is used). By adding a default case to a switch statement one gives up the compiler's ability to support us to write correct code without good reason. This rule should be dropped, or even reverted into "do not ever use default: and lobby the ISO consortium to remove it form the language".

hasselmm avatar Dec 18 '23 10:12 hasselmm