mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-23 02:00:32 +08:00
re PR c++/18150 (Should enable -Wsequence-point for C++)
2006-02-07 Dirk Mueller <dmueller@suse.com> PR c++/18150 * doc/invoke.texi (-Wsequence-point): Update documentation that -Wsequence-point is implemented for C++ as well. From-SVN: r110719
This commit is contained in:
parent
f5e2061b45
commit
7127d9c7d1
@ -1,3 +1,9 @@
|
||||
2006-02-07 Dirk Mueller <dmueller@suse.com>
|
||||
|
||||
PR c++/18150
|
||||
* doc/invoke.texi (-Wsequence-point): Update documentation
|
||||
that -Wsequence-point is implemented for C++ as well.
|
||||
|
||||
2006-02-07 Eric Botcazou <ebotcazou@libertysurf.fr>
|
||||
|
||||
* config/sol26.h (CPP_SUBTARGET_SPEC): Accept -pthread.
|
||||
|
@ -2526,14 +2526,14 @@ This warning is enabled by @option{-Wall}.
|
||||
@item -Wsequence-point
|
||||
@opindex Wsequence-point
|
||||
Warn about code that may have undefined semantics because of violations
|
||||
of sequence point rules in the C standard.
|
||||
of sequence point rules in the C and C++ standards.
|
||||
|
||||
The C standard defines the order in which expressions in a C program are
|
||||
evaluated in terms of @dfn{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
|
||||
The C and C++ standards defines the order in which expressions in a C/C++
|
||||
program are evaluated in terms of @dfn{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
|
||||
@code{&&}, @code{||}, @code{? :} or @code{,} (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.
|
||||
@ -2547,11 +2547,11 @@ 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
|
||||
have undefined behavior; the C and C++ standards specify 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 @code{a = a++;}, @code{a[n]
|
||||
@ -2560,16 +2560,13 @@ 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
|
||||
The 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 the GCC readings page, at
|
||||
@w{@uref{http://gcc.gnu.org/readings.html}}.
|
||||
|
||||
This warning is enabled by @option{-Wall}.
|
||||
This warning is enabled by @option{-Wall} for C and C++.
|
||||
|
||||
@item -Wreturn-type
|
||||
@opindex Wreturn-type
|
||||
|
Loading…
x
Reference in New Issue
Block a user