4 ms·
If you take the address of different functions, the standard requires those to compare unequal. However if you merely call functions and never take their addres
by ynik 4y ago
If you take the address of different functions, the standard requires those to compare unequal.
However if you merely call functions and never take their address, the standard doesn't put any requirements on that, so inlining etc. is legal.
But without LTO, it's impossible for the compiler to know whether a non-inline function with external linkage will be called or have its address taken, so the compiler must ensure that it has a unique address.
- leni536 4y agoThere are linker level optimizations aside outside of LTO that can merge functions. gold's --icf option comes to mind, with --icf=safe meant to be conforming.
- dahart 4y agoGood example of an Observer Effect in programming! If you look at fn addresses they do one thing, and if you don’t they do another. :P
- menaerus 4y agoAll that sounds ... reasonable? What I didn't agree with is the "requiring all functions to have different addresses" argument. It's invalidated both by the compiler (e.g. inlining) and linker (e.g. code folding).