4 ms·
It's not "undefined behaviour". It's "implementation-defined behaviour". Undefined behaviour would be, if the compiler thinks that it always happens, it (the c
by tomp 5y ago
It's not "undefined behaviour". It's "implementation-defined behaviour".
Undefined behaviour would be, if the compiler thinks that it always happens, it (the compiler) can do anything, including e.g. transforming the whole program into
int main() {
return -1;
}
In Go's case, the compiler performs no such shenanigans - it just compiles your code as-is, and it's your responsibility to make sure it's correct - but exactly because it's not undefined behaviour, the analysis is much simpler than in C/C++ - there's no funny business going on in the compiler, and therefore all effects of the data race are local (in code) (i.e. no "nasal deamons").