I know that uninitialized variables don't have a particular set value, but I want to know how these uninitialized values are actually decided, either by the compiler or at runtime.
I find that if i run the below code, different outputs will occur:
#include <stdio.h>
int main() {
int *ptr;
printf("%p\n", ptr);
return 0;
}
Output: (clang)
$ clang a.c -o a; ./a
0x7fffed5e33c0
$ clang a.c -o a; ./a
0x7ffe81aa8660
...
Output: (gcc)
$ gcc a.c -o a; ./a
(nil)
How exactly are uninitialized values decided?