On Tue, May 22, 2007, Peter Hartley wrote:

> Hi there,
> 
> Having just downloaded GCC 4.2.0 and discovered that it can't build
> OpenSSL (not even in the snapshots AFAICT), I'd like to offer a possible
> solution.
> 
> The earlier thread on openssl-dev explains that OpenSSL chooses to cast
> the function pointers, not the parameters, to achieve type-safety; i.e.
> to ensure that errors occur if the wrong types are passed to the
> XYZ_of() functions.
> 
> So how about using expressions of the form
>          (void*)(1 ? x : ((T*)NULL))
> instead? That way, if x isn't of the right type, GCC will warn because
> the ?: gets different types in the two branches. Meanwhile the function
> itself is getting called with the correct types, and while OpenSSL is
> still "deceiving" the type system, it's doing so only via function
> pointers (so there's no way that the compiler, examining any one
> translation unit, can "tell" that deception is being attempted). And the
> compiler should easily spot that the condition ("1") is always true, and
> so generate no extra code compared to the direct, non-typesafe call.
> 
> Attached is a patch against SNAP-20070516 which lets all the tests pass
> under GCC 4.2.0 (on ia32 and amd64).
> 

Well I had a chance to test this and it seems OK as far as it goes. It doesn't
however cover all cases. If it can be made to work with -Wall -Werror
-pedantic -DDEBUG_SAFESTACK and possibly a few other options I've forgotten
(the ones in the debug-steve target) that would be great.

I'm buried under other work myself at the moment so haven't had a chance to
extend it myself.

Steve.
--
Dr Stephen N. Henson. Email, S/MIME and PGP keys: see homepage
OpenSSL project core developer and freelance consultant.
Funding needed! Details on homepage.
Homepage: http://www.drh-consultancy.demon.co.uk
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       openssl-dev@openssl.org
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to