C++ Logo


Advanced search

Re: [SG12] EWG Requests feedback/suggestions on Core Issue 1555

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Thu, 14 May 2020 10:13:35 +0300
On Thu, 14 May 2020 at 08:22, Ville Voutilainen
<ville.voutilainen_at_[hidden]> wrote:
> On Thu, 14 May 2020 at 01:35, Richard Smith via SG12
> <sg12_at_[hidden]> wrote:
> >>> The status quo in the standard is:
> >>> 1) Language linkage is part of the function type.
> >>> 2) Initializing a function pointer with a wrong-language-linkage function (pointer) is a type error.
> >>> 3) Explicitly casting a function pointer to the wrong type and calling it is UB.
> >>> (a) the status quo: the standard continues to say the same thing and vendors continue to ignore it,
> >>> (b) we remove point (1) above and break the targets relying on it, or
> >>> (c) we remove point (2) above.
> > Wow, this is embarrassing, that's still wrong. Should be:
> > """
> > To me it seems like (a) and (b) are not acceptable resolutions, and EWG didn't like conditionally-supported-(c). So maybe we should be considering conditionally-supported-(b) (which would simply be standardizing existing practice).
> > """
> Funny. From a programmer perspective, I would prefer removing all of
> points 1, 2, and 3. I may be wrong,
> but removing point 1 seems to result in points 2 and 3 being removed.
> If I program with the false hope that 1/2/3 don't exist, what target
> platforms is my code currently not portable to?
> What platforms is it portable to?

If I understand things correctly, there is a 100% portable work-around
for this snag, though: whenever I think
I need an address of an extern "C" function, wrap it in a lambda and
use the pointer-to-function conversion
of the lambda.

Received on 2020-05-14 02:16:51