Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#17 closed defect (fixed)

Can't assign 0 to function pointer

Reported by: Thierry Delisle Owned by: Rob Schluntz <rschlunt@…>
Priority: minor Component: cfa-cc
Version: 1.0 Keywords:
Cc:

Description

This code crashes the compiler:

int main() {
	int (*foo)(int) = 0;
}

Change History (3)

comment:1 Changed 7 years ago by a3moss

There's a commented-out line 808 in prelude.cf, that looks like it would do the right thing:
// forall( ftype FT ) void ?{}( FT * *, zero_t );

It looks like Rob put it in in commit 0b150ecc back in late May -- Rob, do you remember why it's commented out?

comment:2 Changed 7 years ago by Rob Schluntz <rschlunt@…>

Owner: set to Rob Schluntz <rschlunt@…>
Resolution: fixed
Status: newclosed

In 969ee0d:

conversion of zero_t to function type does not require tuple specialization [fixes #17]

comment:3 Changed 7 years ago by Rob Schluntz

That's an interesting observation. I'm not sure why it's commented, but it might be necessary for assertions?

In any case, I've handled the zero_t case separately for tuple specialization, since zero_t is special.

Note: See TracTickets for help on using tickets.