Hi, If you're using the same compiler text book that I used (we implemented a Tiger compiler, too), then I pity you... :-) I believe this is expected behavior in C. "If" statements expect a "boolean" expression, which is interpreted as meaning a non-zero result is true, zero is false. Basically, it's really an integer expression. Symtab cannot be converted to an integer (or, if it can, the compiler doesn't realize it) and cannot therefore be used in the "if" statement. The pointer to Symtab, however, can be converted to an integer, and can therefore be used in the expression. The net result of using a pointer is that if the statement is true, then it means the pointer (not the location being pointed to) has a value. Otherwise, it's NULL (zero). Cheers, Lyle -----Original Message----- From: gcc-help-owner@xxxxxxxxxxx [mailto:gcc-help-owner@xxxxxxxxxxx] On Behalf Of Silver Chandrakant L. Sent: Wednesday, March 10, 2004 12:50 PM To: gcc-help@xxxxxxxxxxx Subject: query related to semantic behaviourial comparision in C thru gcc Hi, I want to ask you something related to the behaviour i found in C, actually compiled thru GCC 3.2.2 The problem is or could be in the semantic behaviour. ~~ ~~~~~~~~ Please note the following excerpt from the attached file program symdef.c ~~~~~~~~~~~~~~~~~~~ ~~~~~~~~ void printSymtab(void) { Symtab *tptr; Symtab t; puts("**************\n\t\tSymTable**************"); puts(" Name PIB PIH BlkNo "); printf("%u", t); if (t) ; if (tptr); if (*tptr); return; } `````````````````````````````````````````````` Compilation ~~~~~~~~~~~ [u02139@cs123]$ gcc -Wall symdef.c symdef.c: In function `printSymtab': symdef.c:84: invalid operands to binary != symdef.c:88: invalid operands to binary != [u02139@cs123]$ `````````````````````````````````````````````` The error/semantic behaviour to be pointed out is, when we print the variable "t" it is allowed, but when comparison is done implicit or explicit it gives an error. void printSymtab(void) { Symtab *tptr; Symtab t; puts("**************\n\t\tSymTable**************"); puts(" Name PIB PIH BlkNo "); printf("%u", t); <-------------ALLOWED if (t) ; <-------------NOT ALLOWED (line 84) if (tptr); <-------------This is OKAY if (*tptr); <---------NOT ALLOWED/possibly it is error (line 88) return; } Why so ? could please explain me this semantic behaviour. When allowed in one case can also be implemented/used in other case. Actually it shd be allowed in either cases. I'm doing CC(compiler construction) course in our department and was working out for Tiger language. I just started writing code for the semantic analysis phase, and during compilation such error was encountered. Actually, line 88 was done by mistake, but helped get into these other things. The files used for compilation are attached. Pleaze help me, Waiting for your response. Bye & take care. -- -SilverZ. -- Always forgive your enemies - Nothing annoys them so much. -------------------------------------- Silver Chandrakant L MCA (Batch 2002) IInd year University of Pune. India. chandrakant_silver@xxxxxxxxxxx