[gnu.gcc.bug] Legal ansi?

schmidt@crimee.ics.uci.edu (Doug Schmidt) (10/05/88)

Hi,

   Is the following short code legal Ansi-C?  gcc -ansi accepts it,
gcc -pedantic rejects it, and the Sun 4.0 cc compiler also rejects it.

thanks,

   Doug

----------------------------------------
typedef int ITEM_TYPE;

typedef struct Tree Tree;
struct Tree {
   ITEM_TYPE Item;
   char Tag;
   Tree *Left;
   Tree *Right;
} *Root;


int Test ( P, Item ) 
Tree     *P;
ITEM_TYPE Item;
{      
  (( P->Item > Item ) ? P->Left : P->Right ) = (Tree *) malloc(sizeof(Tree));
}
----------------------------------------

drh@notecnirp.Princeton.EDU (Dave Hanson) (10/05/88)

In article <765@paris.ics.uci.edu> Doug Schmidt <schmidt@crimee.ics.uci.edu> writes:
	Hi,
	
	   Is the following short code legal Ansi-C?  gcc -ansi accepts it,
	gcc -pedantic rejects it, and the Sun 4.0 cc compiler also rejects it.
	
	...
	{      
	  (( P->Item > Item ) ? P->Left : P->Right ) = (Tree *) malloc(sizeof(Tree));
	}

no. conditional expressions are not l-values.