Tech News
← Home  ·  All topics

C And C

2 GoKawiil briefs on this topic

2018 blog post advocates index-handles over C/C++ pointers for memory management

A developer with over 15 years of experience in large C++ codebases describes replacing raw and smart pointers with 'index-handles' as a technique for dynamic memory management. The post, updated in November 2018, adds a method using a per-slot generation counter to prevent 'handle collisions', building on an earlier discussion of pointer- and allocation-free programming.

Compiler optimizations expose hidden UB risk in C/C++ type punning

A developer traced a hard-to-find bug to type punning via pointer casts, which behaves correctly at -O0 but breaks under -O2 optimization. The root cause is that pointer casts violate strict aliasing rules and constitute undefined behavior in C, even though they compile and run correctly on most platforms, and C++ treats type distinctions even more strictly than C.