Why can this code run successfully in Code::block. The IDB just reports
warning: \"reference to local variable ‘tmp’ returned\",
You are causing an undefined behaviour. The standard doesn't tell what happens in that case, however your compiler detected it.