On Fri, Jan 18, 2008 at 05:45:49PM +0100, ecolbus@voila.fr wrote:
If you put a malloc attribute on the allocator and no free attribute
on the deallocator, you can get bugs indeed. GIGO.
The future should be quite nice because:
- the compiler can not know that kmalloc does not have an alias to
the pointer tucked somewhere accessible by other non-inline functions
(as kfree is), especially since it does have aliases in practice, so
it cannot prove to "not read/written otherwise" part without the
malloc attribute
- if you add the (non-standard C) malloc attribute to kmalloc, then
you also add the free attribute to kfree which tells the compiler
that the pointer is invalid after the call, which ensures no
accesses will be moved after it
OG.
--