Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maximum number of else statements in C++

Tags:

c++

I have some legacy code for a messaging system implemented with a huge if/else if/else if... block. When I wanted to add a new else block Visual Studio 2010 has "internal compiler error".

Do you know if is defined by the C++ standard or implementation defined maximum number of else statements? If is implementation defined where may I find the maximum number for Visual Studio 2010?

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

like image 960
Mircea Ispas Avatar asked Apr 06 '13 19:04

Mircea Ispas


2 Answers

The C++ Standard does not require a minimum. It has a recommended minimum, but not a required one.

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

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

like image 145
Johannes Schaub - litb Avatar answered Nov 08 '22 11:11

Johannes Schaub - litb


Here are the Visual Studio C++ compiler limits (courtesy of Google).

MSVC compiler limits

like image 22
brian beuning Avatar answered Nov 08 '22 11:11

brian beuning