Opened 20 months ago
#273 new defect
Comma expression wrecks typechecking for address of array element
Reported by: | mlbrooks | Owned by: | |
---|---|---|---|
Priority: | minor | Component: | cfa-cc |
Version: | 1.0 | Keywords: | |
Cc: |
Description
#ifndef __cforall int printf(const char *, ...); #endif struct Animal { int lunch; }; int main() { struct Animal theTiger; theTiger.lunch = 1; struct Animal menagerie[42]; menagerie[0 ].lunch = 2; menagerie[17].lunch = 3; struct Animal * myPet; void show() { printf("%d ", myPet->lunch); } myPet = & theTiger ; show(); myPet = (0, & theTiger ); show(); myPet = (0, menagerie ); show(); myPet = (0, menagerie+17 ); show(); myPet = & menagerie[17] ; show(); myPet = (0, & menagerie[17] ); show(); // here printf("\n"); }
gcc -x c demo.cfa; ./a.out
cfa demo.cfa; ./a.out
GCC, Expected and Actual: Compiles and prints 1 1 2 3 3 3
CFA, Expected: Same as GCC
CFA, Actual: "error: incompatible types when assigning to type ‘struct Animal *’ from type ‘struct Animal’" on the line marked "here"
Note: See
TracTickets for help on using
tickets.