[patch] bus error in gcry_free
christianbiere at gmx.de
Thu Feb 1 20:39:10 CET 2007
Werner Koch wrote:
> On Thu, 1 Feb 2007 16:24, christianbiere at gmx.de said:
> >> return (pool_okay
> >> && p >= pool
> >> && p < (const void*)((const char*)pool+pool_size));
> > If p points into the pool or just one byte after it, everything is fine and
> > well-defined. Otherwise, the behaviour of this code is completely undefined.
> > A compile may optimize this into this:
> > return pool_okay && p != (const void*)((const char*)pool+pool_size);
> Sorry, I may be temporary blind but I can't see how you come to this
> conclusion. What is wrong with:
> (const void*) ((const char*)pool + pool_size)
You're looking at the wrong part.
> ? How can the comparison be optimized away?
Because passing any other pointer yields either true or has undefined behaviour.
Searching the web for the phrase
"In all other cases, the behavior is undefined."
will take you directly to relevant section of the standard.
More information about the Gcrypt-devel