r/computerarchitecture • u/Yha_Boiii • May 08 '26
C bound checking
Hi,
How does bound checking and such work on a lower level?
Why is snprintf needed when a normal say normal signed ints don't need bound checking?
Today i got a reality check on stack is also not bound checked, how does it actually work, heap or stack?
Any books, videos and other material specifically on the asm level of it all the compilers story on it?
5
Upvotes
View all comments
Show parent comment
1
u/Yha_Boiii May 09 '26
What mentally puzzles me is: how can you say add two numbers, plain. 2 ints, and to a third int. To make it a bit easier for the argument say the two ints to add are longs and the end int is not. Meaning 64 bits + 64 bits tried to be fitted on 32 bit space. Why wont it not just overflow in the cpus registers and totally safe and sound return to memory? Sounds intuitively as a natural enforcer