Microchip Technology SW006023-3N Datenbogen
Compiler Command Line Driver
2012 Microchip Technology Inc.
DS51686E-page 67
-Wsequence-point
Warn about code that may have undefined semantics because
of violations of sequence point rules in the C standard.
The C standard defines the order in which expressions in a C
program are evaluated in terms of sequence points, which
represent a partial ordering between the execution of parts of the
program: those executed before the sequence point and those
executed after it. These occur after the evaluation of a full
expression (one which is not part of a larger expression), after
the evaluation of the first operand of a &&, ||, ? : or , (comma)
operator, before a function is called (but after the evaluation of its
arguments and the expression denoting the called function), and
in certain other places. Other than as expressed by the
sequence point rules, the order of evaluation of subexpressions
of an expression is not specified. All these rules describe only a
partial order rather than a total order, since, for example, if two
functions are called within one expression with no sequence
point between them, the order in which the functions are called is
not specified. However, the standards committee has ruled that
function calls do not overlap.
It is not specified when between sequence points modifications
to the values of objects take effect. Programs whose behavior
depends on this have undefined behavior. The C standard
specifies that “Between the previous and next sequence point,
an object shall have its stored value modified, at most once, by
the evaluation of an expression. Furthermore, the prior value
shall be read only to determine the value to be stored.” If a
program breaks these rules, the results on any particular
implementation are entirely unpredictable.
Examples of code with undefined behavior are a = a++;,
a[n] = b[n++]
of violations of sequence point rules in the C standard.
The C standard defines the order in which expressions in a C
program are evaluated in terms of sequence points, which
represent a partial ordering between the execution of parts of the
program: those executed before the sequence point and those
executed after it. These occur after the evaluation of a full
expression (one which is not part of a larger expression), after
the evaluation of the first operand of a &&, ||, ? : or , (comma)
operator, before a function is called (but after the evaluation of its
arguments and the expression denoting the called function), and
in certain other places. Other than as expressed by the
sequence point rules, the order of evaluation of subexpressions
of an expression is not specified. All these rules describe only a
partial order rather than a total order, since, for example, if two
functions are called within one expression with no sequence
point between them, the order in which the functions are called is
not specified. However, the standards committee has ruled that
function calls do not overlap.
It is not specified when between sequence points modifications
to the values of objects take effect. Programs whose behavior
depends on this have undefined behavior. The C standard
specifies that “Between the previous and next sequence point,
an object shall have its stored value modified, at most once, by
the evaluation of an expression. Furthermore, the prior value
shall be read only to determine the value to be stored.” If a
program breaks these rules, the results on any particular
implementation are entirely unpredictable.
Examples of code with undefined behavior are a = a++;,
a[n] = b[n++]
and a[i++] = i;. Some more complicated
cases are not diagnosed by this option, and it may give an
occasional false positive result, but in general it has been found
fairly effective at detecting this sort of problem in programs.
occasional false positive result, but in general it has been found
fairly effective at detecting this sort of problem in programs.
-Wswitch
Warn whenever a switch statement has an index of enumeral
type and lacks a case for one or more of the named codes of that
enumeration. (The presence of a default label prevents this
warning.) case labels outside the enumeration range also
provoke warnings when this option is used.
type and lacks a case for one or more of the named codes of that
enumeration. (The presence of a default label prevents this
warning.) case labels outside the enumeration range also
provoke warnings when this option is used.
-Wsystem-headers
Print warning messages for constructs found in system header
files. Warnings from system headers are normally suppressed
on the assumption that they usually do not indicate real
problems and would only make the compiler output harder to
read. Using this command line option tells the compiler to emit
warnings from system headers as if they occurred in user code.
However, note that using -Wall in conjunction with this option
does not warn about unknown pragmas in system headers. For
that, -Wunknown-pragmas must also be used.
files. Warnings from system headers are normally suppressed
on the assumption that they usually do not indicate real
problems and would only make the compiler output harder to
read. Using this command line option tells the compiler to emit
warnings from system headers as if they occurred in user code.
However, note that using -Wall in conjunction with this option
does not warn about unknown pragmas in system headers. For
that, -Wunknown-pragmas must also be used.
-Wtrigraphs
Warn if any trigraphs are encountered (assuming they are
enabled).
enabled).
TABLE 3-8:
WARNING AND ERROR OPTIONS IMPLIED BY ALL WARNINGS
Option
Definition