Skip to main content

IAR Embedded Workbench for RX 5.20

Implementation-defined behavior for C89

In this section:

This section describes how the compiler handles the implementation-defined areas of the C language standard C89. If you are using Standard C instead of C89, see Implementation-defined behavior for Standard C.

Descriptions

The descriptions follow the same order as the ISO appendix. Each item covered includes references to the ISO chapter and section (in parenthesis) that explains the implementation-defined behavior.

Translation

Diagnostics (5.1.1.3)

Diagnostics are produced in the form:

filename,linenumber level[tag]: message

where filename is the name of the source file in which the error was encountered, linenumber is the line number at which the compiler detected the error, level is the level of seriousness of the message (remark, warning, error, or fatal error), tag is a unique tag that identifies the message, and message is an explanatory message, possibly several lines.

Environment

Arguments to main (5.1.2.2.2.1)

The function called at program startup is called main. No prototype was declared for main, and the only definition supported for main is:

int main(void)

To change this behavior for the DLIB runtime environment, see System initialization.

Interactive devices (5.1.2.3)

The streams stdin and stdout are treated as interactive devices.

Identifiers

Significant characters without external linkage (6.1.2)

The number of significant initial characters in an identifier without external linkage is 200.

Significant characters with external linkage (6.1.2)

The number of significant initial characters in an identifier with external linkage is 200.

Case distinctions are significant (6.1.2)

Identifiers with external linkage are treated as case-sensitive.

Characters

Source and execution character sets (5.2.1)

The source character set is the set of legal characters that can appear in source files. It is dependent on the chosen encoding for the source file. See Text encodings. By default, the source character set is Raw.

The execution character set is the set of legal characters that can appear in the execution environment. These are the execution character set for character constants and string literals and their encoding types:

Execution character set

Encoding type

L

UTF-32

u

UTF-16

U

UTF-32

u8

UTF-8

none

The source character set

Table 107. Execution character sets and their encodings 


The DLIB runtime environment needs a multibyte character scanner to support a multibyte execution character set. See Locale.

Bits per character in execution character set (5.2.4.2.1)

The number of bits in a character is represented by the manifest constant CHAR_BIT. The standard include file limits.h defines CHAR_BIT as 8.

Mapping of characters (6.1.3.4)

The mapping of members of the source character set (in character and string literals) to members of the execution character set is made in a one-to-one way. In other words, the same representation value is used for each member in the character sets except for the escape sequences listed in the ISO standard.

Unrepresented character constants (6.1.3.4)

The value of an integer character constant that contains a character or escape sequence not represented in the basic execution character set or in the extended character set for a wide character constant generates a diagnostic message, and will be truncated to fit the execution character set.

Character constant with more than one character (6.1.3.4)

An integer character constant that contains more than one character will be treated as an integer constant. The value will be calculated by treating the leftmost character as the most significant character, and the rightmost character as the least significant character, in an integer constant. A diagnostic message will be issued if the value cannot be represented in an integer constant.

A wide character constant that contains more than one multibyte character generates a diagnostic message.

Converting multibyte characters (6.1.3.4)

See Locale.

Range of 'plain' char (6.2.1.1)

A ‘plain’ char has the same range as an unsignedchar.

Integers

Range of integer values (6.1.2.5)

The representation of integer values are in the two's complement form. The most significant bit holds the sign—1 for negative, 0 for positive and zero.

See Basic data types—integer types, for information about the ranges for the different integer types.

Demotion of integers (6.2.1.2)

Converting an integer to a shorter signed integer is made by truncation. If the value cannot be represented when converting an unsigned integer to a signed integer of equal length, the bit-pattern remains the same. In other words, a large enough value will be converted into a negative value.

Signed bitwise operations (6.3)

Bitwise operations on signed integers work the same way as bitwise operations on unsigned integers—in other words, the sign-bit will be treated as any other bit, except for the operator >> which will behave as an arithmetic right shift.

Sign of the remainder on integer division (6.3.5)

The sign of the remainder on integer division is the same as the sign of the dividend.

Negative valued signed right shifts (6.3.7)

The result of a right-shift of a negative-valued signed integral type preserves the sign-bit. For example, shifting 0xFF00 down one step yields 0xFF80.

Floating point

Representation of floating-point values (6.1.2.5)

The representation and sets of the various floating-point numbers adheres to IEC 60559. A typical floating-point number is built up of a sign-bit (s), a biased exponent (e), and a mantissa (m).

See Basic data types—floating-point types, for information about the ranges and sizes for the different floating-point types: float and double.

Converting integer values to floating-point values (6.2.1.3)

When an integral number is cast to a floating-point value that cannot exactly represent the value, the value is rounded (up or down) to the nearest suitable value.

Demoting floating-point values (6.2.1.4)

When a floating-point value is converted to a floating-point value of narrower type that cannot exactly represent the value, the value is rounded (up or down) to the nearest suitable value.

Arrays and pointers

size_t (6.3.3.4, 7.1.1)

See size_t, for information about size_t.

Conversion from/to pointers (6.3.4)

See Casting, for information about casting of data pointers and function pointers.

ptrdiff_t (6.3.6, 7.1.1)

See ptrdiff_t, for information about the ptrdiff_t.

Registers

Honoring the register keyword (6.5.1)

User requests for register variables are not honored.

Structures, unions, enumerations, and bitfields

Improper access to a union (6.3.2.3)

If a union gets its value stored through a member and is then accessed using a member of a different type, the result is solely dependent on the internal storage of the first member.

Padding and alignment of structure members (6.5.2.1)

See the section Basic data types—integer types, for information about the alignment requirement for data objects.

Sign of 'plain' bitfields (6.5.2.1)

A 'plain' int bitfield is treated as asigned int bitfield. All integer types are allowed as bitfields.

Allocation order of bitfields within a unit (6.5.2.1)

Bitfields are allocated within an integer from least-significant to most-significant bit.

Can bitfields straddle a storage-unit boundary (6.5.2.1)

Bitfields cannot straddle a storage-unit boundary for the chosen bitfield integer type.

Integer type chosen to represent enumeration types (6.5.2.2)

The chosen integer type for a specific enumeration type depends on the enumeration constants defined for the enumeration type. The chosen integer type is the smallest possible.

Qualifiers

Access to volatile objects (6.5.3)

Any reference to an object with volatile qualified type is an access.

Declarators

Maximum numbers of declarators (6.5.4)

The number of declarators is not limited. The number is limited only by the available memory.

Statements

Maximum number of case statements (6.6.4.2)

The number of case statements (case values) in a switch statement is not limited. The number is limited only by the available memory.

Preprocessing directives

Character constants and conditional inclusion (6.8.1)

The character set used in the preprocessor directives is the same as the execution character set. The preprocessor recognizes negative character values if a 'plain' character is treated as a signed character.

Including bracketed filenames (6.8.2)

For file specifications enclosed in angle brackets, the preprocessor does not search directories of the parent files. A parent file is the file that contains the #include directive. Instead, it begins by searching for the file in the directories specified on the compiler command line.

Including quoted filenames (6.8.2)

For file specifications enclosed in quotes, the preprocessor directory search begins with the directories of the parent file, then proceeds through the directories of any grandparent files. Thus, searching begins relative to the directory containing the source file currently being processed. If there is no grandparent file and the file is not found, the search continues as if the filename was enclosed in angle brackets.

Character sequences (6.8.2)

Preprocessor directives use the source character set, except for escape sequences. Thus, to specify a path for an include file, use only one backslash:

#include "mydirectory\myfile"

Within source code, two backslashes are necessary:

file = fopen("mydirectory\\myfile","rt");
Recognized pragma directives (6.8.6)

In addition to the pragma directives described in Pragma directives, the following directives are recognized and will have an indeterminate effect. If a pragma directive is listed both in Pragma directives and here, the information provided in Pragma directives overrides the information here.

  • alignment

  • baseaddr

  • building_runtime

  • can_instantiate

  • codeseg

  • cspy_support

  • define_type_info

  • do_not_instantiate

  • early_dynamic_initialization

  • function

  • function_effects

  • hdrstop

  • important_typedef

  • instantiate

  • keep_definition

  • library_default_requirements

  • library_provides

  • library_requirement_override

  • memory

  • module_name

  • no_pch

  • once

  • system_include

  • warnings

Default __DATE__ and __TIME__ (6.8.8)

The definitions for __TIME__ and __DATE__ are always available.

DLIB runtime library functions

Note

Some items in this list only apply when file descriptors are supported by the library configuration. For more information about runtime library configurations, see The DLIB runtime environment.

NULL macro (7.1.6)

The NULL macro is defined to 0.

Diagnostic printed by the assert function (7.2)

The assert() function prints:

filename:linenr expression ‑‑ assertion failed

when the parameter evaluates to zero.

Domain errors (7.5.1)

NaN (Not a Number) will be returned by the mathematic functions on domain errors.

Underflow of floating-point values sets errno to ERANGE (7.5.1)

The mathematics functions set the integer expression errno to ERANGE (a macro in errno.h) on underflow range errors.

fmod() functionality (7.5.6.4)

If the second argument to fmod() is zero, the function returns NaNerrno is set to EDOM.

signal() (7.7.1.1)

The signal part of the library is not supported.

Note

The default implementation of signal does not perform anything. Use the template source code to implement application-specific signal handling. See signal and raise, respectively.

Terminating newline character (7.9.2)

stdout stream functions recognize either newline or endoffile(EOF) as the terminating character for a line.

Blank lines (7.9.2)

Space characters written to the stdout stream immediately before a newline character are preserved. There is no way to read the line through the stdin stream that was written through the stdout stream.

Null characters appended to data written to binary streams (7.9.2)

No null characters are appended to data written to binary streams.

Files (7.9.3)

Whether the file position indicator of an append-mode stream is initially positioned at the beginning or the end of the file, depends on the application-specific implementation of the low-level file routines.

Whether a write operation on a text stream causes the associated file to be truncated beyond that point, depends on the application-specific implementation of the low-level file routines. See Briefly about input and output (I/O).

The characteristics of the file buffering is that the implementation supports files that are unbuffered, line buffered, or fully buffered.

Whether a zero-length file actually exists depends on the application-specific implementation of the low-level file routines.

Rules for composing valid file names depends on the application-specific implementation of the low-level file routines.

Whether the same file can be simultaneously open multiple times depends on the application-specific implementation of the low-level file routines.

remove() (7.9.4.1)

The effect of a remove operation on an open file depends on the application-specific implementation of the low-level file routines. See Briefly about input and output (I/O).

rename() (7.9.4.2)

The effect of renaming a file to an already existing filename depends on the application-specific implementation of the low-level file routines. See Briefly about input and output (I/O).

%p in printf() (7.9.6.1)

The argument to a %p conversion specifier, print pointer, to printf() is treated as having the type void *. The value will be printed as a hexadecimal number, similar to using the %x conversion specifier.

%p in scanf() (7.9.6.2)

The %p conversion specifier, scan pointer, to scanf() reads a hexadecimal number and converts it into a value with the type void *.

Reading ranges in scanf() (7.9.6.2)

A - (dash) character is always treated as a range symbol.

File position errors (7.9.9.1, 7.9.9.4)

On file position errors, the functions fgetpos and ftell store EFPOS in errno.

Message generated by perror() (7.9.10.4)

The generated message is:

usersuppliedprefix:errormessage
Allocating zero bytes of memory (7.10.3)

The calloc(), malloc(), and realloc() functions accept zero as an argument. Memory will be allocated, a valid pointer to that memory is returned, and the memory block can be modified later by realloc.

Behavior of abort() (7.10.4.1)

The abort() function does not flush stream buffers, and it does not handle files, because this is an unsupported feature.

Behavior of exit() (7.10.4.3)

The argument passed to the exit function will be the return value returned by the main function to cstartup.

Environment (7.10.4.4)

The set of available environment names and the method for altering the environment list is described in getenv.

system() (7.10.4.5)

How the command processor works depends on how you have implemented the system function. See system.

Message returned by strerror() (7.11.6.2)

The messages returned by strerror() depending on the argument is:

Argument

Message

EZERO

no error

EDOM

domain error

ERANGE

range error

EFPOS

filepositioningerror

EILSEQ

multi-byteencodingerror

<0 || >99

unknown error

all others

error nnn

Table 108. Message returned by strerror()—DLIB runtime environment 


The time zone (7.12.1)

The local time zone and daylight savings time implementation is described in __time32, __time64.

clock() (7.12.2.1)

From where the system clock starts counting depends on how you have implemented the clock function. See clock.