C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Drop same sequence of tokens for inline

From: Tom Honermann <tom_at_[hidden]>
Date: Thu, 4 May 2023 15:24:47 -0400
On 5/4/23 1:11 PM, sasho648 via Std-Proposals wrote:
> So why does inline functions need to have the same sequence of tokens
> in different TU - imagine in a TU there is a preprocessor define that
> changes the function definition - it would make sense this not to be UB.
>
> In C inline functions have internal linkage - it would make the same
> sense for C++.
>
> Like I don't see a reason requiring inline functions to have the same
> body - regardless of the statement above.

Taking the address of a (inline or otherwise) function in one
translation unit must produce a pointer equivalent to that produced in
another translation unit; they must both point to the same function.
Thus, you can't have different implementations in different translation
units.

Tom.

Received on 2023-05-04 19:24:48