Glenn, David, could you have a look at the warnings below? I turned on
gcc4.6's -Wsequence-point on my new Suse 12.1 test machine and found
these new warnings in my ast-open.2012-02-14 build log:
src/lib/libpp/ppsearch.c:132:2: warning: operation on 'xp' may be
undefined [-Wsequence-point]
src/lib/libpp/ppsearch.c:132:2: warning: operation on 'xp' may be
undefined [-Wsequence-point]
src/lib/libpp/ppsearch.c:132:2: warning: operation on 'xp' may be
undefined [-Wsequence-point]
src/lib/libcs/css.c:284:4: warning: operation on 'css->conkey' may be
undefined [-Wsequence-point]
src/lib/libcs/css.c:299:17: warning: operation on 'css->conkey' may be
undefined [-Wsequence-point]
src/lib/libcs/css.c:654:10: warning: operation on 'css->newkey' may be
undefined [-Wsequence-point]
src/lib/libcs/css.c:847:10: warning: operation on 'css->conkey' may be
undefined [-Wsequence-point]
src/lib/libcs/css.c:850:10: warning: operation on 'css->conkey' may be
undefined [-Wsequence-point]
src/cmd/ksh93/sh/lex.c:1139:8: warning: operation on '_Fcin.fcptr' may
be undefined [-Wsequence-point]
src/cmd/ksh93/sh/lex.c:1563:5: warning: operation on '_Fcin.fcptr' may
be undefined [-Wsequence-point]
src/cmd/ksh93/sh/lex.c:1139:8: warning: operation on '_Fcin.fcptr' may
be undefined [-Wsequence-point]
src/cmd/ksh93/sh/lex.c:1563:5: warning: operation on '_Fcin.fcptr' may
be undefined [-Wsequence-point]
src/cmd/3d/vcs.c:303:55: warning: operation on 'len' may be undefined
[-Wsequence-point]
src/cmd/cs/vcs_src/vcs_tag.c:40:83: warning: operation on 'len' may be
undefined [-Wsequence-point]
src/lib/librecsort/rskey.c:418:15: warning: operation on 'kp->shuffle'
may be undefined [-Wsequence-point]
src/cmd/kshlib/dss/dss.c:766:23: warning: operation on 'root' may be
undefined [-Wsequence-point]
src/cmd/mailx/imap.c:1999:15: warning: operation on 'state.trace' may
be undefined [-Wsequence-point]
src/cmd/mailx/imap.c:2489:6: warning: operation on 's' may be
undefined [-Wsequence-point]
src/lib/libvcodex/vcio.c:137:5: warning: operation on 'v' may be
undefined [-Wsequence-point]
src/lib/libvcodex/Vcdelta/vcdelta.c:222:11: warning: operation on 'l'
may be undefined [-Wsequence-point]

IMO these warnings are bad because every compiler, platform or code
optimizer may interpret such statements in different order, which may
result in weired bugs which are quite hard to find.

The gcc manual page defines -Wsequence-point:
...
           Warn about code that may have undefined semantics because
of violations of sequence point rules in the C and C++ standards.

           The C and C++ standards defines the order in which
expressions in a C/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 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 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 "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.
...

Olga
-- 
      ,   _                                    _   ,
     { \/`o;====-    Olga Kryzhanovska   -====;o`\/ }
.----'-/`-/     [email protected]   \-`\-'----.
 `'-..-| /       http://twitter.com/fleyta     \ |-..-'`
      /\/\     Solaris/BSD//C/C++ programmer   /\/\
      `--`                                      `--`

_______________________________________________
ast-developers mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-developers

Reply via email to