I ran into a few subtle bugs around casts in C—mostly pointer precedence and intent not being obvious in reviews.
Things like (long *)buf + 1 are easy to misread at a glance.
I tried making casts more explicit with small macros (CAST_PTR1, etc.) and adding some compile-time checks.
Curious how others deal with this—warnings, conventions, or just careful review?
tnelsond4•24m ago
GCC -Wall what tells me about most implicit casts going on (which I mostly ignore). But not all of them.
I think these cast problems are ultimately something that the compiler can and should catch. And a stronger type enforcement system would be nice, but also I use C so i don't have to deal with rust's nonsense
yairlenga•1h ago
Things like (long *)buf + 1 are easy to misread at a glance.
I tried making casts more explicit with small macros (CAST_PTR1, etc.) and adding some compile-time checks.
Curious how others deal with this—warnings, conventions, or just careful review?