[comp.sys.ibm.pc.rt] Problem with hc

olovsson@ce.chalmers.se. (Tomas Olovsson) (11/21/89)

Hello everyone!

I have problems with hc accepting constructions like:

    main()
    {
	int i;

	(int)i = 0;
    }

% hc c.c
E "c.c",L5/C12:	(syntactic)  unexpected symbol:'='
REPAIR:   ';' replaces '='@"c.c",L5/C12
1 user error   No warnings   


All other C-compilers seem to accept this construction. For hc the line has to
be changed to:

    ((int) i) = 0;


Is this correct (or intentional)?

-----------------------------------------------------------------------------
     Tomas Olovsson
     olovsson@ce.chalmers.se

raeburn@athena.mit.edu (Ken Raeburn) (11/26/89)

In article <1732@mathrt0.math.chalmers.se> olovsson@ce.chalmers.se writes:
>I have problems with hc accepting constructions like:
>    main()
>    {
>	int i;
>	(int)i = 0;
>    }
...
>All other C-compilers seem to accept this construction. For hc the line has to
>be changed to:
>
>    ((int) i) = 0;
>
>Is this correct (or intentional)?

I would hope that the former "problem" is intentional; it is correct.

The latter construct is essentially the same as the first.  It is also
incorrect, and the compiler should have complained.

Casts do not produce lvalues; you cannot assign to their results.
(See the proposed ANSI C standard, section 3.3.4, Cast Operators.)

-- Ken