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'd started using inline functions which add a minimal extra overhead. That works in a lot of places but can get seriously messy in others. Would the compiler (or possibly other compilers) give out a warning that a test was always true? 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]