tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: EV_SET() better C++ compat with alternative implementations



On 12.08.2019 05:56, Christos Zoulas wrote:
> 
>> The original problem is udata of intptr_t insted of void* (like in
>> FreeBSD) and with C++ compilers it's not possible to cast it cleanly to
>> intptr_t without alternative approaches.
>>
>> This keeps breaking C++ users and we need to patch 3rd party code from
>> the caller level.
>>
>> It used to break C ones too, but we have introduced a cast to workaround it.
>>
>> As we fix it for C ones, I think we should fix it for C++ ones as well.
>>
>> 3 solutions:
>>
>> - Keep patching it on caller level for C++
>> - Keep inventing workarounds on callee level for C++
>> - Change the type of udata to void* in our source code.
>>
>> Templates and c++ features are difficult as the language is reinventing
>> its each decade.
>>
>> Can we go for changing the udata type to void*? This will make all
>> compatibility problems to go away.
> 
> I am not sure what the best solution is. If we go adding pragma's
> then we can use regular casts and disable the -Wold-style-cast
> warning with a pragma. Otherwise you seem to have a working
> template-specialization based solution. But as you wrote perhaps
> the best solution is to go back to using void * for it, although this
> means breaking existing software workarounds.
> 
>> Compilers probably apply different warning rules for system headers.
> 
> Ah, this is the -Wsystem-headers which we enable in our .mk files.
> This $#$%#!$$# was what also disabled the array indexing warnings
> in the <ctype.h> macros. In our (NetBSD) opinion, -Wsystem-headers
> is a mis-feature designed to work around broken system headers that
> can cause poor application space implementations to not cause warnings.
> 
> christos
> 

I think that the current checked in version and template proposal are
vulnerable to at least warnings comings from headers for NULL being
treated as an integer.

Unfortunately, #pragma does not help much (it helped as there was a typo
disabling it), as we can disable a warning, but.. a code that triggers
it in 3rd party code has the warning reenabled.

As I have discussed with C++ people, they suggested to keep fixing it on
the caller level or changing udata type. This is the spirit of C++ that
types are stricter.

I would suggest one of the two ways change headers or fix callers. If we
still can change intptr_t to void*, than and should do it. If we cannot
do it, than we should patch users to our type.

Independently, we could change our system header definition of NULL to
nullptr. This is allowed for C++11 and newer and will be picky about
real bugs of NULL misuse.

Attachment: signature.asc
Description: OpenPGP digital signature



Home | Main Index | Thread Index | Old Index