lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Tue, Apr 29, 2014 at 10:12:57AM -0300, Roberto Ierusalimschy wrote:
> > [...] A pointer is completely and utterly
> > invalid after it's been freed, so even copying its value is invalid, as well
> > as dereferencing it.
> 
> I could not find that in the standard (about copying a freed
> pointer). The C standard talks about "trap representations", but that is
> related (as the name implies) to the representation of a value, which
> does not change with a call to 'free'.
> 
> -- Roberto

I suppose it's debatable, but IMO it's an unwarranted assumption that the
set of trap representations cannot change. I posted the question to
comp.lang.c, and the consensus so far is that a pointer with an
indeterminate value (which happens after free) can cause a trap.

	https://groups.google.com/forum/#!topic/comp.lang.c/IU5mNmYDfwE

James Kuyper gave the most complete answer so far:

	https://groups.google.com/d/msg/comp.lang.c/IU5mNmYDfwE/F4FREJRLLb4J

Something Kuyper pointed out which I missed was the definition of operators
on pointer values--their behavior is undefined for indeterminate pointer
values.