Is it because the array is treated as a pointer that the cPP array does not report an error when it is out of bounds?

int array [3] = {1,2,3};
std::cout < std::cout < std::cout < the above code output is
0
-858993460
because array [3] is directly treated as * (array+3)?
then why is the output of array [3] and array [4] the same?

CPP
Jun.04,2021

Does

report no error because array [3] is directly treated as * (array+3) ?

can be understood in this way. From the point of view of the urination of CPP, this is the simplest, fastest and convenient for all kinds of magic uses. Detection of crossing boundaries should be left to libraries, or higher-level languages.

then why array [3] , array [4] output the same result?

the Visual CPP compiler populates uninitialized memory with 0xCC in debug mode. If you output a string, it is hot. If the output int32, is-858993460.

 

personal opinion:

the compiler does not detect out-of-bounds errors.
only when the runtime accesses the illegal address of the system, the system throws an error to the program, and the program continues to push

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b30b68-2bd1e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b30b68-2bd1e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?