|
|
Log in / Subscribe / Register

Losing the magic

Losing the magic

Posted Dec 5, 2022 21:40 UTC (Mon) by Sesse (subscriber, #53779)
In reply to: Losing the magic by iabervon
Parent article: Losing the magic

Out of curiosity, what is the trick? Using sizeof?


to post comments

Losing the magic

Posted Dec 5, 2022 22:06 UTC (Mon) by iabervon (subscriber, #722) [Link]

I think the original was (0 ? (*fn)(arg) : store_callback(fn, arg)), and using enough optimization that the direct call won't be generated. Once people demonstrated the benefit and possibility of doing this sort of testing, a later innovation was the sizeof trick to make the code really explicitly execute as "discard a small integer", which will be nothing following even unoptimized code generation (since even minimal register allocation will just discard the code).


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds