[fpc-pascal] default parameter single = NaN

Jonas Maebe jonas.maebe at elis.ugent.be
Mon Jun 20 23:43:41 CEST 2016


On 20/06/16 22:59, David Emerson wrote:
> Error: function header doesn't match the previous declaration
>
> for a (non-method) function that does exactly match its previous
> declaration:
>
> function make_scale_matrix (zx:single; zy:single=NaN):t_2d_affine;
>
> I use "NaN" extensively to indicate a null / not specified value, so it
> would really be a drag to lose this feature. Although the header exactly
> matches the previous declaration, it now objects to these NaN default
> parameters.

It's probably due to a peciularity of the "NaN" value itself: if you ask 
a floating point unit to compare NaN with NaN, the returned result must 
always be "not equal" even though the bit patterns match exactly. To fix 
this, the compiler will have to compare the bit patterns of floating 
point default parameters rather than their values as floating point numbers.

Please file a bug report.


Jonas


More information about the fpc-pascal mailing list