Is it legal for the compiler to degrade the time complexity of a program? Is this considered observable behavior?
The C standard doesn’t actually have a time complexity model, neither for its primitive operations, nor its library functions, so compilers are allowed to do pretty much anything that preserves program semantics (observable behavior). The C++ standard only gives complexity guarantees only for some its library functions, and says (17.5.1.4 [structure.specifications]): Complexity requirements specified in … Read more