C++ Logo


Advanced search

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

From: David Vandevoorde <daveed_at_[hidden]>
Date: Thu, 14 May 2020 12:57:51 -0400
> On May 14, 2020, at 4:00 AM, Richard Smith via SG12 <sg12_at_[hidden]> wrote:
[ About language linkage being part of function types…]
> I hope someone who maintains an implementation for such a target will speak up. (I think someone did when this was last asked, though, so I don't think this is a theoretical or legacy concern. I'd be very happy to be wrong about that.)

Our front end can be configured in this respect:
  - Whether C and C++ language linkage function types are distinct
  - If they are not distinct, whether they can be implicitly converted from one to another
    (and some added configurability to decide whether those implicit conversions are
     enabled by default or require a command-line option)

For those customers who have shared they configurations with us, most appear to keep the types distinct but allow implicit conversions between them. So the following example is accepted:

$ cat -> r.cpp
extern "C" typedef int F(void);
extern "C++" typedef int FPP(void);

constexpr int g(F) { return 1; }
constexpr int g(FPP) { return 2; };

F f;
FPP fpp;
F *pf = fpp;

static_assert(g(f) == 1);
static_assert(g(fpp) == 2);
$ ./cfe --c++20 r.cpp

(The “major” implementations would complain g has a duplicate definition.)


Received on 2020-05-14 12:00:57