Opened 7 years ago

Closed 7 years ago

#53 closed defect (fixed)

Tuple costs are incorrect

Reported by: Rob Schluntz Owned by: Rob Schluntz
Priority: minor Component: cfa-cc
Version: 1.0 Keywords:
Cc:

Description

Tuple costs are not computed correctly. For example:

[long, long] f() {
  return [0, -1];
}

The difference between the two alternatives being that 1 is converted to signed int or to signed long, and both expressions are given the same cost.

test.c:34:1 error: Cannot choose between 2 alternatives for expression
Applying untyped: 
  Name: ?{}
...to: 
  Cast of:
    Variable Expression: _retval_f: tuple of types
      signed long int
      signed long int

  ... to:
    reference to tuple of types
      signed long int
      signed long int

  Untyped Tuple:
    constant expression (0 0: zero_t)
    Applying untyped: 
      Name: -?
    ...to: 
      constant expression (1 1: one_t)


Alternatives are:
Cost ( 0, 0, 0, 0 ): Tuple Assignment Expression, with stmt expr:
     Statement Expression: 
       CompoundStmt
         Declaration of __multassign_L6: reference to lvalue signed long int with initializer (not constructed)
           Simple Initializer: Cast of:
             Tuple Index Expression, with tuple:
               Variable Expression: _retval_f: tuple of types
                 signed long int
                 signed long int
               with index: 0

           ... to:
             reference to lvalue signed long int

         Declaration of __multassign_L7: reference to lvalue signed long int with initializer (not constructed)
           Simple Initializer: Cast of:
             Tuple Index Expression, with tuple:
               Variable Expression: _retval_f: tuple of types
                 signed long int
                 signed long int
               with index: 1

           ... to:
             reference to lvalue signed long int

         Declaration of __multassign_R6: zero_t with initializer (maybe constructed)
           Constructor initializer: 
           ... initially constructed with Implicit Ctor Dtor Statement
             ... with Ctor/Dtor: Expression Statement:
                 Application of
                   Variable Expression: ?{}: function
                   ... with parameters
                     intrinsic reference to zero_t
                     intrinsic zero_t
                   ... returning nothing 

                 ... to arguments
                   Cast of:
                     Variable Expression: __multassign_R6: zero_t
                   ... to:
                     reference to zero_t
                   constant expression (0 0: zero_t)



         Declaration of __multassign_R7: signed int with initializer (maybe constructed)
           Constructor initializer: 
           ... initially constructed with Implicit Ctor Dtor Statement
             ... with Ctor/Dtor: Expression Statement:
                 Application of
                   Variable Expression: ?{}: function
                   ... with parameters
                     intrinsic reference to signed int
                     intrinsic signed int
                   ... returning nothing 

                 ... to arguments
                   Cast of:
                     Variable Expression: __multassign_R7: signed int
                   ... to:
                     reference to signed int
                   Application of
                     Variable Expression: -?: function
                     ... with parameters
                       intrinsic signed int
                     ... returning 
                       _retval__operator_unaryminus: signed int
                       ... with attributes: 
                         Attribute with name: unused


                   ... to arguments
                     Cast of:
                       constant expression (1 1: one_t)
                     ... to:
                       signed int




         Expression Statement:
           Tuple:
             Application of
               Variable Expression: ?{}: function
               ... with parameters
                 intrinsic reference to signed long int
                 intrinsic signed long int
               ... returning nothing 

             ... to arguments
               Variable Expression: __multassign_L6: reference to lvalue signed long int
               Cast of:
                 Variable Expression: __multassign_R6: zero_t
               ... to:
                 signed long int

             Application of
               Variable Expression: ?{}: function
               ... with parameters
                 intrinsic reference to signed long int
                 intrinsic signed long int
               ... returning nothing 

             ... to arguments
               Variable Expression: __multassign_L7: reference to lvalue signed long int
               Cast of:
                 Variable Expression: __multassign_R7: signed int
               ... to:
                 signed long int



 (types:
   void 
 )
 Environment: 

Cost ( 0, 0, 0, 0 ): Tuple Assignment Expression, with stmt expr:
     Statement Expression: 
       CompoundStmt
         Declaration of __multassign_L4: reference to lvalue signed long int with initializer (not constructed)
           Simple Initializer: Cast of:
             Tuple Index Expression, with tuple:
               Variable Expression: _retval_f: tuple of types
                 signed long int
                 signed long int
               with index: 0

           ... to:
             reference to lvalue signed long int

         Declaration of __multassign_L5: reference to lvalue signed long int with initializer (not constructed)
           Simple Initializer: Cast of:
             Tuple Index Expression, with tuple:
               Variable Expression: _retval_f: tuple of types
                 signed long int
                 signed long int
               with index: 1

           ... to:
             reference to lvalue signed long int

         Declaration of __multassign_R4: zero_t with initializer (maybe constructed)
           Constructor initializer: 
           ... initially constructed with Implicit Ctor Dtor Statement
             ... with Ctor/Dtor: Expression Statement:
                 Application of
                   Variable Expression: ?{}: function
                   ... with parameters
                     intrinsic reference to zero_t
                     intrinsic zero_t
                   ... returning nothing 

                 ... to arguments
                   Cast of:
                     Variable Expression: __multassign_R4: zero_t
                   ... to:
                     reference to zero_t
                   constant expression (0 0: zero_t)



         Declaration of __multassign_R5: signed long int with initializer (maybe constructed)
           Constructor initializer: 
           ... initially constructed with Implicit Ctor Dtor Statement
             ... with Ctor/Dtor: Expression Statement:
                 Application of
                   Variable Expression: ?{}: function
                   ... with parameters
                     intrinsic reference to signed long int
                     intrinsic signed long int
                   ... returning nothing 

                 ... to arguments
                   Cast of:
                     Variable Expression: __multassign_R5: signed long int
                   ... to:
                     reference to signed long int
                   Application of
                     Variable Expression: -?: function
                     ... with parameters
                       intrinsic signed long int
                     ... returning 
                       _retval__operator_unaryminus: signed long int
                       ... with attributes: 
                         Attribute with name: unused


                   ... to arguments
                     Cast of:
                       constant expression (1 1: one_t)
                     ... to:
                       signed long int




         Expression Statement:
           Tuple:
             Application of
               Variable Expression: ?{}: function
               ... with parameters
                 intrinsic reference to signed long int
                 intrinsic signed long int
               ... returning nothing 

             ... to arguments
               Variable Expression: __multassign_L4: reference to lvalue signed long int
               Cast of:
                 Variable Expression: __multassign_R4: zero_t
               ... to:
                 signed long int

             Application of
               Variable Expression: ?{}: function
               ... with parameters
                 intrinsic reference to signed long int
                 intrinsic signed long int
               ... returning nothing 

             ... to arguments
               Variable Expression: __multassign_L5: reference to lvalue signed long int
               Variable Expression: __multassign_R5: signed long int



 (types:
   void 
 )
 Environment: 

Change History (1)

comment:1 Changed 7 years ago by Rob Schluntz

Resolution: fixed
Status: assignedclosed

This appears to work now, resolving as fixed.

Note: See TracTickets for help on using tickets.