Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
cokernel_hacker
on Sept 5, 2024
|
parent
|
context
|
favorite
| on:
Undefined behavior in C is a reading error (2021)
That works for a lot of behavior but not everything. For example:
int f(int x) { static int y[] = {42, 43}; return y[x]; }
What behavior should `f(-1)` or `f(100)` have? What is sensible?
Y_Y
on Sept 5, 2024
[–]
Desugar to pointer arithmetic, try to do an dereference like
*(y-1)
and more than likely segfault, or return the value at that address if it's somehow valid.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: