2 ms·
I originally thought this essay would be about the fact that something like constexpr should appear to be the same platform as your target. This is an interest
by tialaramex 5y ago
I originally thought this essay would be about the fact that something like constexpr should appear to be the same platform as your target.
This is an interesting property. For example, if I insist on writing down a 64-bit integer in memory and then staring at the individual bytes, the platform determines the layout of that structure. You don't want to know what the layout is for your compiler but for your target.
Floating point maths is often tricky in this world. You expect the constexpr platform to have the same behaviour as your target, but emulating that (assuming you aren't in the trivial case of compiling on the target) can mean some pretty fearsome work that can't be justified. So, maybe the ARM CPU at runtime calculates a very slightly different value for the "constant" internal_damping_factor from the value used in constexpr functions on this x86-64 cross compiler...
However it turns out I once again underestimated how far out C++ wants to go here. Shine on you crazy diamond.
- rowanG077 5y agoFloating point can be easily handled as long as the compiler says this is the way cte floats are handled irrespective of platform. It only gets harder if you must match the target platform. And even that could be pretty easily done with qemu for most platforms I'd wager.