[patch] bus error in gcry_free
wk at gnupg.org
Fri Feb 2 09:55:19 CET 2007
On Thu, 1 Feb 2007 20:39, christianbiere at gmx.de said:
> Because passing any other pointer yields either true or has undefined behaviour.
You mean using pointers with relational operators. C-99 says:
6.5.8 Relational operators
[#5] When two pointers are compared, the result depends on
the relative locations in the address space of the objects
pointed to. If two pointers to object or incomplete types
both point to the same object, or both point one past the
last element of the same array object, they compare equal.
If the objects pointed to are members of the same aggregate
object, pointers to structure members declared later compare
greater than pointers to members declared earlier in the
structure, and pointers to array elements with larger
subscript values compare greater than pointers to elements
of the same array with lower subscript values. All pointers
to members of the same union object compare equal. If the
=> expression P points to an element of an array object and the
=> expression Q points to the last element of the same array
=> object, the pointer expression Q+1 compares greater than P.
In all other cases, the behavior is undefined.
Well, strictly interpreting you may be right. However, this is
irrelevant given that we assume a linear address space. I also doubt
that C-89 has the same requirements and that is what we code for.
Anyway, such an interpretation of the specs is similar to the rule
that you can't clear a structure with pointer elements by using
memset. Almost everyone is ignoring that and I don't want to get
back to the time of segmented memory architectures.
More information about the Gcrypt-devel