Maximum number of else statements in C ++

I have legacy messaging code implemented with a huge if/else if/else if block .... When I wanted to add a new else block, Visual Studio 2010 had an “internal compiler error”.

Do you know if defined by the C ++ standard or a certain maximum number of else ? If an implementation is defined, where can I find the maximum number for Visual Studio 2010?

For historical reasons, I cannot change the code, even if the implementation ... is not very wise.

+7
source share
2 answers

The C ++ standard does not require a minimum. It has a recommended minimum, but is not required.

Nesting levels of compound operators, iteration control structures, and selection control structures [256].

Once the implementation limit is exceeded, the behavior is undefined.

+12
source

Here are the limits for the Visual Studio C ++ compiler (kindly provided by Google).

MSVC Compiler Limitations

+1
source

All Articles