Opened 7 years ago

Closed 2 years ago

#44 closed defect (invalid)

zero_t causes warnings because it always codgens as long int

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

Description

zero_t should intelligently codegen as long int, void *, or void (*)() depending on the context.

An example where this is necessary:

typedef void (*fptr_t)();
void f(int);

int main() {
  fptr_t x;
  x = f;
}

The assignment function is correctly chosen as

forall( ftype FT ) FT *     ?=?( FT *    &, zero_t );

But codegens as

((void)(__x__PF___2=((long int )__f__F_i__1)));

Which causes a warning in gcc:

warning: assignment makes pointer from integer without a cast

Change History (2)

comment:1 Changed 6 years ago by Thierry Delisle

The example code no longer compiles:

CFA Version 1.0.0 (debug)
test.cfa:6:1 error: No reasonable alternatives for expression Applying untyped: 
  Name: ?=?
...to: 
  Name: x
  Name: f

comment:2 Changed 2 years ago by Thierry Delisle

Resolution: invalid
Status: newclosed

The example code does not compile, fixing the code to compile still doesn't produce the warning.

Note: See TracTickets for help on using tickets.