Date: Wed, 30 Apr 2025 10:47:57 -0700
On Wednesday, 30 April 2025 10:42:55 Pacific Daylight Time Robin Savonen
Söderholm wrote:
> I'm curious with this compile-time/runtime representation difference. We can
> sort things in compile time. If I make a sorted compile-time array of
> function pointers (sorted by the regular "ptr < ptr" sense) and then in
> runtime do a binary search to check if a certain function exists in that
> array, would that be well-defined behaviour, and how?
You can only order pointers that belong to the same array. Anything else is
UB. That would include trying to see if &i < &j for two namespace-scope
integer variables and definitely two functions.
Söderholm wrote:
> I'm curious with this compile-time/runtime representation difference. We can
> sort things in compile time. If I make a sorted compile-time array of
> function pointers (sorted by the regular "ptr < ptr" sense) and then in
> runtime do a binary search to check if a certain function exists in that
> array, would that be well-defined behaviour, and how?
You can only order pointers that belong to the same array. Anything else is
UB. That would include trying to see if &i < &j for two namespace-scope
integer variables and definitely two functions.
-- Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org Principal Engineer - Intel DCAI Platform & System Engineering
Received on 2025-04-30 17:48:01