Menu

#371 ConstantFixedExpressionEvaluator does not check if FIT is possible  Edit

compiler
open
None
2025-11-30
2022-01-21
No

What should happen here?

DCL f FIXED(7) INIT(1024 FIT f);

1024 does not fit into a FIXED(7).
The runtime system would induce a FixedRangeSignal.
Thus, I expect that the compiler emits an error message.
Test is in testsuite/tickets/371_fit.prl

the test should that there are several problems:

  1. DCL f FIXED(7) INIT(1024 FIT f); aborts with INIT: could not abort initializer
  2. DCL g FIXED(7); DCL f FIXED(7) INIT(1024 FIT g); aborts with constant expected

Reasons:

  1. The symbol is not in the symbol table while INIT is evaluated
  2. the grammar for constantFixedExpressionFit expects a constantFixedExpression instead of a name or ID?

@2: The German language report also denotes Faktor ::= .... [ FIT konstanter-FIT-Ausdruck ]
This bug seam to be very old!

by the way:

  • The possibility of TOFIXED as factor is missing in the grammar
  • a negative sign is ignored

Discussion

  • Rainer Müller

    Rainer Müller - 2022-01-21
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -5,6 +5,8 @@
     1024 does not fit into a FIXED(7).
     The runtime system  would induce a `FixedRangeSignal`.
     Thus I expect that the compiler emits an error message.
    +Test is in `testsuite/tickets/371_fit.prl`
    +
    
     **the test should that there are several problems:**
    
     1. DCL f FIXED(7) INIT(1024 FIT f); aborts with INIT: could not abort initializer
    
     
  • Rainer Müller

    Rainer Müller - 2022-01-21
    • summary: ConstantFixedExpressionEvaluator does not chgeck if FIT is possible --> ConstantFixedExpressionEvaluator does not check if FIT is possible
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -20,4 +20,6 @@
     @2: The german language report denotes also Faktor ::= .... [ FIT konstanter-FIT-Ausdruck ]
     This bug seam to be very old!
    
    -**by the way:** The possibility of TOFIXED as factor is missing in the grammar
    +**by the way:** 
    +* The possibility of TOFIXED as factor is missing in the grammar
    +* a negative sign is igored
    
     
  • Rainer Müller

    Rainer Müller - 2022-01-22

    The ignored '-' is now treated

    A tests with the Werum compiler showed, that

    • FIT in INIT expects a constant FIXED expression and it has no effect on the code except a warning is issued
    • FIT in regular expressions just performs a type cast - no range checks occur

    RTOS-UH: The language report of RTOS-UH does not contain the word 'FIT'

    Next steps:

    1. The semantic of FIT on a constant FIXED expression must become defined
    2. the constantFixedExpressionEvaluator must be modified towards the defined behavior
     

    Last edit: Rainer Müller 2022-01-22
  • Rainer Müller

    Rainer Müller - 2022-01-22

    Decision after a short discussion:

    1. FIT in constantFixedExpressions are not necessary, since the expressions are evaluated with required precision by the compiler, the result must fit into the target type e.g. in INIT-lists
    2. FIT has an fixed operand on rhs. If the lhs has a larger precision as rhs, an error message occurs
    3. FIT in constant FIXED expressions must be elaborated in the language report

    Fixed with commit 060c8abced6a99360da9a0251cc98a8094a4fc9b

     
  • Marcel Schaible

    Marcel Schaible - 2022-12-18
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -4,7 +4,7 @@
    
     1024 does not fit into a FIXED(7).
     The runtime system  would induce a `FixedRangeSignal`.
    -Thus I expect that the compiler emits an error message.
    +Thus, I expect that the compiler emits an error message.
     Test is in `testsuite/tickets/371_fit.prl`
    
    
    @@ -17,9 +17,9 @@
    
     1. The symbol is not in the symbol table while INIT is evaluated
     2. the grammar for constantFixedExpressionFit expects a constantFixedExpression instead of a name or ID?  
    
    -@2: The german language report denotes also Faktor ::= .... [ FIT konstanter-FIT-Ausdruck ]
    +@2: The German language report also denotes Faktor ::= .... [ FIT konstanter-FIT-Ausdruck ]
     This bug seam to be very old!
    
     **by the way:** 
    
     * The possibility of TOFIXED as factor is missing in the grammar
    -* a negative sign is igored
    +* a negative sign is ignored
    
    • status: open --> accepted
    • assigned_to: Marcel Schaible
     
  • Marcel Schaible

    Marcel Schaible - 2025-11-30
    • status: accepted --> open
     

Anonymous
Anonymous

Add attachments
Cancel





MongoDB Logo MongoDB