Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardC++inlining and the as-if ruleSingle-choice MCQ

Why can the compiler legally print only "done" here (eliding the loop entirely) under the as-if rule, even though the loop appears to do work?

#include <cstdio> int main(){ unsigned long s = 0; for (unsigned long i = 0; i < 1000000000UL; ++i) s += i; // s is never used after this printf("done\n"); }