Language Features
SC100 C Compiler
3-35
3.4.1.2.5 K&R/PCC mode differences: expressions and statements
The following are the differences for expressions and statements relative to the default standard mode:
Assignment is allowed between pointers and integers, and between incompatible pointer types,
without an explicit cast. A warning is issued.
A field selection of the form
p
->
field
is allowed even if
p
does not point to a
struct
or
union
that contains
field
. In this context,
p
must be a pointer or an integer. Similarly,
x
.
field
is
allowed even if
x
is not a
struct
or
union
that contains
field
. In this case,
x
must be an
lvalue
.
In both cases, if
field
is declared as a
field
in more than one
struct
or
union
, it must have
the same offset in all instances.
Overflows detected while folding signed integer operations on constants will cause warnings rather
than errors.
A warning will be issued for an
&
operator applied to an array. The type of such an operation is
“
address of array element
”
rather than
“
address of array
”
.
For the shift operators
<<
and
>>
, the usual arithmetic conversions are done on the operands as they
would be for other binary operators. The right operand is then converted to
int
, and the result type
is the type of the left operand. In ANSI C, the integral promotions are done on the two operands
separately, and the result type is the type of the left operand. The effect of this difference is that, in
pcc
mode, a
long
shift count will force the shift to be done as
long
.
String literals will not be shared. Identical string literals will cause multiple copies of the string to
be allocated.
The expression
sizeof
may be applied to bit-fields. The size is that of the underlying type (for
example
unsigned int
).
Any
lvalues
cast to a type of the same size remain
lvalues
, except when they involve a floating
point conversion.
A warning rather than an error is issued for integer constants that are larger than can be
accommodated in an
unsigned long
. The value is truncated to an acceptable number of low-order
bits.
Expressions in a
switch
statement are cast to
int
. This differs from the ANSI C definition in that
a
long
expression may be truncated.
The promotion rules for integers are different:
unsigned char
and
unsigned short
are
promoted to
unsigned int
.