On Thu, 20 Mar 2025 13:30:27 +0100 (CET) Richard Biener <rguent...@suse.de> wrote:
> @@ -4126,7 +4137,11 @@ count: %empty { $$ = 0; } > if( e ) { // verify not floating point with nonzero fraction > auto field = cbl_field_of(e); > assert(is_literal(field)); > - if( field->data.value_of() != > size_t(field->data.value_of()) ) { > + REAL_VALUE_TYPE vi; > + HOST_WIDE_INT vii = real_to_integer (TREE_REAL_CST_PTR > (field->data.value_of())); > + real_from_integer (&vi, VOIDmode, vii, SIGNED); > + if( !real_identical (TREE_REAL_CST_PTR > (field->data.value_of()), > + &vi) ) { > nmsg++; > error_msg(@NAME, "invalid PICTURE count '(%s)'", > field->data.initial ); I just want to verify this still does what we want. We had > - if( field->data.value_of() != size_t(field->data.value_of()) ) { When cbl_field_t::data::value_of returned _Float128, that line compared a _Float128 to its value as a size_t. If the number was negative, had a fractional component, or was too large, the test failed. Now cbl_field_t::data::value_of returns a tree. Steps: 1. produce HOST_WIDE_INT vii from the tree 2. set REAL_VALUE_TYPE vi from vii 3. use real_identical to compare vi to the original The comment for real_identical says it's a bitwise comparison. That's not the same as saying the floating point value can be represented exactly as a size_t. If that's guaranteed to work, great, thanks. If not, how do I test the sign, magnitude and fraction of the value? <future work> Until now, numeric literals in the parser were represented as _Float128 and in the CDF (cdf.y) as int64_t. Neither is strictly correct. ISO says numeric literals are fixed-point, not floating: "The value of a fixed-point numeric literal is the algebraic quantity represented by the characters in the fixed-point numeric literal. The size of a fixed-point numeric literal is equal to the number of digits in the string of characters in the literal." That means 01 ONE-GRAND CONSTANT 10 * 10 * 10. should be a fixed-point value of 3 bytes with scaling factor of 0. As of now, I believe we're using a tree of REAL_CST, but in the future I guess we should switch to FIXED_CST. </future work> --jkl