Opened 4 years ago

Last modified 3 years ago

#44 new defect

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 (1)

comment:1 Changed 3 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

Note: See TracTickets for help on using tickets.