Red Hat ENTERPRISE LINUX 3 - USING GCC Using Instructions page 36

Using the gnu compiler collection (gcc)
Hide thumbs Also See for ENTERPRISE LINUX 3 - USING GCC:
Table of Contents

Advertisement

30
In C, every
else
is
. This is often not what the programmer expected, as illustrated in the above example
if (b)
by indentation the programmer chose. When there is the potential for this confusion, GCC will
issue a warning when this flag is specified. To eliminate the warning, add explicit braces around
the innermost
if
resulting code would look like this:
{
if (a)
{
if (b)
foo ();
else
bar ();
}
}
-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
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 have 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
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.
The present implementation of this option only works for C programs. A future implementation
may also work for C++ programs.
The C standard is worded confusingly, therefore there is some debate over the precise meaning of
the sequence point rules in subtle cases. Links to discussions of the problem, including proposed
formal definitions, may be found on our readings page, at http://gcc.gnu.org/readings.html.
-Wreturn-type
Warn whenever a function is defined with a return-type that defaults to
statement with no return-value in a function whose return-type is not
return
For C++, a function without return type always produces a diagnostic message, even when
-Wno-return-type
headers.
branch belongs to the innermost possible
statement so there is no way the
&&
is specified. The only exceptions are
Chapter 4. GCC Command Options
if
could belong to the enclosing
else
,
,
or
(comma) operator, before a function is
||
? :
,
,
a = a++;
a[n] = b[n++]
main
statement, which in this example
and
a[i++] = i;
. Also warn about any
int
.
void
and functions defined in system
. The
if
.

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the ENTERPRISE LINUX 3 - USING GCC and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Enterprise linux 3

Table of Contents