Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardC++strict aliasing rulesSingle-choice MCQ

What does the call to f() return when compiled with strict-aliasing optimizations enabled (e.g. -O2)?

int f() { int n = 0; short* p = reinterpret_cast<short*>(&n); p[0] = 1; return n; }