Commit 7127d9c7 by Dirk Mueller Committed by Dirk Mueller

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
parent f5e2061b
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> 2006-02-07 Eric Botcazou <ebotcazou@libertysurf.fr>
* config/sol26.h (CPP_SUBTARGET_SPEC): Accept -pthread. * config/sol26.h (CPP_SUBTARGET_SPEC): Accept -pthread.
......
...@@ -2526,14 +2526,14 @@ This warning is enabled by @option{-Wall}. ...@@ -2526,14 +2526,14 @@ This warning is enabled by @option{-Wall}.
@item -Wsequence-point @item -Wsequence-point
@opindex Wsequence-point @opindex Wsequence-point
Warn about code that may have undefined semantics because of violations 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 The C and C++ standards defines the order in which expressions in a C/C++
evaluated in terms of @dfn{sequence points}, which represent a partial program are evaluated in terms of @dfn{sequence points}, which represent
ordering between the execution of parts of the program: those executed a partial ordering between the execution of parts of the program: those
before the sequence point, and those executed after it. These occur executed before the sequence point, and those executed after it. These
after the evaluation of a full expression (one which is not part of a occur after the evaluation of a full expression (one which is not part
larger expression), after the evaluation of the first operand of a of a larger expression), after the evaluation of the first operand of a
@code{&&}, @code{||}, @code{? :} or @code{,} (comma) operator, before a @code{&&}, @code{||}, @code{? :} or @code{,} (comma) operator, before a
function is called (but after the evaluation of its arguments and the function is called (but after the evaluation of its arguments and the
expression denoting the called function), and in certain other places. expression denoting the called function), and in certain other places.
...@@ -2547,11 +2547,11 @@ ruled that function calls do not overlap. ...@@ -2547,11 +2547,11 @@ ruled that function calls do not overlap.
It is not specified when between sequence points modifications to the It is not specified when between sequence points modifications to the
values of objects take effect. Programs whose behavior depends on this values of objects take effect. Programs whose behavior depends on this
have undefined behavior; the C standard specifies that ``Between the have undefined behavior; the C and C++ standards specify that ``Between
previous and next sequence point an object shall have its stored value the previous and next sequence point an object shall have its stored
modified at most once by the evaluation of an expression. Furthermore, value modified at most once by the evaluation of an expression.
the prior value shall be read only to determine the value to be Furthermore, the prior value shall be read only to determine the value
stored.''. If a program breaks these rules, the results on any to be stored.''. If a program breaks these rules, the results on any
particular implementation are entirely unpredictable. particular implementation are entirely unpredictable.
Examples of code with undefined behavior are @code{a = a++;}, @code{a[n] 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 ...@@ -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 result, but in general it has been found fairly effective at detecting
this sort of problem in programs. this sort of problem in programs.
The present implementation of this option only works for C programs. A The standard is worded confusingly, therefore there is some debate
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. over the precise meaning of the sequence point rules in subtle cases.
Links to discussions of the problem, including proposed formal Links to discussions of the problem, including proposed formal
definitions, may be found on the GCC readings page, at definitions, may be found on the GCC readings page, at
@w{@uref{http://gcc.gnu.org/readings.html}}. @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 @item -Wreturn-type
@opindex Wreturn-type @opindex Wreturn-type
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment