C++ Logo

std-proposals

Advanced search

Re: [std-proposals] interceptor functions (tested and working on x86_64)

From: David Brown <david.brown_at_[hidden]>
Date: Fri, 1 May 2026 10:39:08 +0200
On 01/05/2026 09:39, Frederick Virchanza Gotham via Std-Proposals wrote:
> In response to David, Jonathan and Thiago chronologically:
>
>
>
> Thiago:
> > What could possibly be the use-case for intercepting printf? How do
> you even
> > know what the mangling of "printf" is (hint: it's not `printf`
> everywhere)?
>
>
>
> Not sure why you're making this point, because the address of 'printf'
> gets resolved in C++, not in assembler, and so the compiler handles the
> mangling. We don't need to know the mangled name of printf.
>

That's not true, AFAIUI. Function addresses are resolved by the linker
- not the compiler.

And for standard functions where the compiler knows exactly what the
function does, or other functions when the compiler can see the source,
the compiler is not in any way obliged to generate direct calls to the
function. gcc will, for example, generate code for

 printf("Hello, world!\n");

with a call to "puts".

Received on 2026-05-01 08:39:13