[comp.sys.amiga] Lattice compiler error

rsbx@beowulf.UUCP (Raymond S Brand) (06/10/88)

#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
#	badc.c
# This archive created: Thu Jun  9 17:33:15 1988
# By:	Raymond S Brand (his computer)
export PATH; PATH=/bin:$PATH
if test -f 'badc.c'
then
	echo shar: will not over-write existing file "'badc.c'"
else
sed 's/^XX//' << \SHAR_EOF > 'badc.c'
XX/*
XX * This module demostrates the Lattice version 4.01 compiler generating
XX * a CXERR: 19 error message;
XX *
XX * Try compiling this with and without pre-precessor symbol BADCODE
XX * defined.
XX *
XX * Raymond S. Brand
XX *
XX */
XX
XX
XX
XXtypedef struct hard_point { float hx, hy; } HardPoint;
XX
XXenum pelem_type { EHeader, EMove, ELine, EArc, ECurve, EClose };
XX
XXstruct path_element
XX {
XX        enum pelem_type ptype;
XX        union {
XX                HardPoint point;
XX                struct arc { int dir; HardPoint centre; float radius, from, to; } arc;
XX                struct bezier { HardPoint x0, x1, x2; } curve;
XX        } pe;
XX        struct path_element *next, *last;
XX };
XX
XXtypedef struct path_element *Path;
XX
XXextern HardPoint NewHardPoint();
XXextern Path NewPath();
XX
XXstatic void Dash (i)
XX   int i;
XX  {
XX   Path p = NewPath();
XX   HardPoint move, here, next;
XX
XX   next = here = move = NewHardPoint();
XX
XX
XX#ifdef BADCODE
XX
XX   next = p->ptype == ELine ? p->pe.point : move;
XX
XX#else
XX
XX   if (p->ptype == ELine)
XX     {
XX      next = p->pe.point;
XX     }
XX   else
XX     {
XX      next = move;
XX     }
XX
XX#endif
XX
XX  }
XX
SHAR_EOF
fi # end of overwriting check
#	End of shell archive
exit 0

toebes@sas.UUCP (John Toebes) (06/12/88)

In article <197@beowulf.UUCP> rsbx@beowulf.UUCP (Raymond S Brand) writes:
>XX * This module demostrates the Lattice version 4.01 compiler generating
>XX * a CXERR: 19 error message;
>XXtypedef struct hard_point { float hx, hy; } HardPoint;
>XX   next = p->ptype == ELine ? p->pe.point : move;
If you look carefully, this program is doing a structure assignment
as the result of a conditional ?: expression.  K&R doesn't explicitely allow
it although ANSI has added support for it.  The only fix with the 4.01 compiler
would be to disallow the construct.  Granted a CXERR is not appropriate.

This brings up the point that any problems with a product should go to
the vendor.  Usenet is not a tech support place for any vendor (nor should
it be as everyone pays for the transfer of information).  [Not meant as
a flame of any sort, I just want to make sure everything is in its place
and I don't miss what I have to do]
/*---------------------All standard Disclaimers apply---------------------*/
/*----Working for but not officially representing SAS or Lattice Inc.-----*/
/*----John A. Toebes, VIII             usenet:...!mcnc!rti!sas!toebes-----*/
/*------------------------------------------------------------------------*/