This is a discussion on Re: OpenSSL breaks with gcc 4.2 - Openssl ; Thus spake Peter Waltenberg > x is still just a pointer to data - so it's the same length in any > case, all > pointers to lvalues are the same length in C. The only issue there is > ...
Thus spake Peter Waltenberg
> x is still just a pointer to data - so it's the same length in any
> case, all
> pointers to lvalues are the same length in C. The only issue there is
> whether it's aligned correctly - that's the programmers problem.
It's not the only problem.
> Mixing something like char *(*d2i)(), and char ** IS problematic,
> those aren't guaranteed to be the same length but as far as I can
> remember OpenSSL doesn't do that.
> d2i is a function (prototype is unknown)
> but I've been told x is a pointer, &p is a pointer, len is long.
> nothing indeterminate about the size of any of those.
Incorrect. When the compiler encounters this statement, if there's no
prototype for d2i() in scope, it is _required_ to act as if the
int d2i(int, int, int);
Since you're passing two pointers and a long, this is simply invalid.
It may work on some platforms, but it's undefined behavior and a
compiler is free to do whatever it wants (including insert code to crash
> C isn't a strongly typed language - there's no language requirement
> an accurate function prototype or that the types of the arguments be
> correct - only that the size of them is correct.
C89 had already deprecated non-prototyped functions. In C99, they're
prohibited, so there is a requirement today.
> C is not the same language as C++, this instance should work with a
> C compiler - whether or not the compiler is passing the arguments via
> the stack or in registers.
Again, not correct. There are implementations that pass ints, longs,
and pointers all in different registers. Some platforms have specific
registers for pointers, just like many have specific registers for
floats/doubles. Others will have the top half of a long corrupted if
sizeof(long)>sizeof(int), which is common on many 64-bit machines.
Stephen Sprunk "God does not play dice." --Albert Einstein
CCIE #3723 "God is an inveterate gambler, and He throws the
K5SSS dice at every possible opportunity." --Stephen Hawking
OpenSSL Project http://www.openssl.org
Development Mailing List email@example.com
Automated List Manager firstname.lastname@example.org