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 11.08.2019 19:19, Kamil Rytarowski wrote:
> On 11.08.2019 19:17, Christos Zoulas wrote:
>> Did you use -Wold-style-cast? We've come full circle now, and what we have seems
>> to be more complicated than what we had before and I am not sure what was the
>> problem in the first place... Can we just step back and understand what is the problem
>> we are trying to solve with all this complexity?
>>

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.

On 11.08.2019 19:28, Christos Zoulas wrote:> I don't see how this is
possible.
>
> [1:27pm] 345>cat t.cpp
> #include <cstdio>
> #include <cstdint>
>
> int
> main(int argc, char *argv[])
> {
>         printf("%jd", (intptr_t)argv[0]);
>         return 0;
> }
> [1:28pm] 346>g++ -std=gnu++11 -Wall -Wold-style-cast t.cpp
> t.cpp: In function 'int main(int, char**)':
> t.cpp:7:32: warning: use of old-style cast [-Wold-style-cast]
>   printf("%jd", (intptr_t)argv[0]);
>                                 ^
>

Compilers probably apply different warning rules for system headers.

Attachment: signature.asc
Description: OpenPGP digital signature



Home | Main Index | Thread Index | Old Index