C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Guarantees over addresses from function pointers created from lambda

From: Thiago Macieira <thiago_at_[hidden]>
Date: Mon, 28 Apr 2025 09:26:41 -0700
On Sunday, 27 April 2025 09:42:31 Pacific Daylight Time Tiago Freire via Std-
Proposals wrote:
> My proposition was that because it could produce smaller binaries (and allow
> for better code optimization) is itself reason enough to make the change.

Why can't the compiler/linker do this under the as-if rule?

How the implement it so that code doesn't break is out of scope for this
discussion. It can probably be done in LTO/LTCG via an optimisation pass that
confirms the function is only called and the address is never otherwise taken.

I would support a proposal giving the compiler a hint that two functions *can*
be merged even if their addresses are taken. [[no_unique_address]] applied to
functions.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel DCAI Platform & System Engineering

Received on 2025-04-28 16:26:45