This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: malloc attributes and realloc


> The specification of realloc does not say the pointer is free()ed.

Now perhaps it is you that is trying to play too much of the language
lawyer. You have to be careful in reading a language standard to always
include the important rule that you can't use the standard to deduce
something that is obviously wrong :-) In particular, if the language
of the standard does not reflect the intent, then it is the intent
that rules, not the language (just as in the case of a contract where
the language of the contract does not reflect the intent of both
parties to the contract -- of course if it reflects one parties
intent and not the other, things get interesting, which is when we
need real lawyers.

After all the standard itself has errors in it (of course), so we need an
approach to reading the standard that does not necessarily assume that
it is 100% correct.

In this case, we know perfectly well that if the realloc has to actually
allocate a new area of storage, then the old area may be freed, whatever
the standard says. Actually the language of the standard seems reasonable
to me, and consistent with this obvious semantic fact!




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]