In GCC, MVSC, Clang, and AppleClang, the code below will compile and always print "no". But when dereferencing the int*, are we actually reading 3 extra bytes into the test variable, and thus it could happen that the code prints "yes" if some of the 3 extra bytes are not 0?
Example Code:
#include <cstdio>
void* fun()
{
static bool value = false;
return &value;
}
int main(int, char**)
{
int test = *static_cast<int*>(fun());
if (test == 0)
{
printf("no");
}
else
{
printf("yes");
}
return 0;
}