How much do most C compilers remove constant expressions? [closed]

At least with macros, C compilers are expected to remove at least most constant math operations. For example, func((4 + 40) * 2) is expected to become func(88) during compilation.

I don't know what happens with something like this:

if (1)
    first();
else
    second();

(which is the same as)

const int mybool = 1;
if (mybool)
    first();
else
    second();

Does this just become first(); on most compilers?

What about:

while(0){
    dostuff();
}

Does this get removed?

If the answer isn't just "They all stay", where is a list of the things C compilers are expected to find and remove (aside from optimization)?



Comments

Popular posts from this blog

Spring Elasticsearch Operations

Object oriented programming concepts (OOPs)

Network Error and Timeout on Authorize.net JS