From 7127d9c7d139e90cb58511b31c5a4a617bce3eea Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Tue, 7 Feb 2006 21:47:55 +0000 Subject: [PATCH] re PR c++/18150 (Should enable -Wsequence-point for C++) 2006-02-07 Dirk Mueller PR c++/18150 * doc/invoke.texi (-Wsequence-point): Update documentation that -Wsequence-point is implemented for C++ as well. From-SVN: r110719 --- gcc/ChangeLog | 6 ++++++ gcc/doc/invoke.texi | 31 ++++++++++++++----------------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index da642fadff1..6149afe467b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2006-02-07 Dirk Mueller + + PR c++/18150 + * doc/invoke.texi (-Wsequence-point): Update documentation + that -Wsequence-point is implemented for C++ as well. + 2006-02-07 Eric Botcazou * config/sol26.h (CPP_SUBTARGET_SPEC): Accept -pthread. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index d68e94d31e6..798d4e79cbb 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -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