My program compiled by tcc produces random higher bytes, too.
I have thought that I have explained, why it works sometimes and sometimes not.
Quite big part of memory are clean bytes (contain zeroes) during running of programs.
So, sometimes your uninitialized int n get such zeros from returned memory of other programs.
When another program is ended, memory parts, which were used by it, are returned to OS.
When your OS start your program, it can give you part of RAM, which was used by another program and it can contains zeros in place, where n is localized.
But the memory allocated by the operating system between two different programs is not cleared (reset to zeroes). So, it can contain bytes, which are zeroes but it can contain any other values, which another program has used in time, when it ended.
I have thought that I have explained, why it works sometimes and sometimes not.
Quite big part of memory are clean bytes (contain zeroes) during running of programs.
So, sometimes your uninitialized int n get such zeros from returned memory of other programs.
When another program is ended, memory parts, which were used by it, are returned to OS.
When your OS start your program, it can give you part of RAM, which was used by another program and it can contains zeros in place, where n is localized.
But the memory allocated by the operating system between two different programs is not cleared (reset to zeroes). So, it can contain bytes, which are zeroes but it can contain any other values, which another program has used in time, when it ended.
Statistics: Posted by ruwolf — 2024-05-31 05:21