This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/16302] gcc fails to warn about some common logic errors


------- Additional Comments From trt at acm dot org  2005-04-29 20:20 -------
The patch given in comment #4 no successfully applies because the warning()
function has new initial parameter.  Also the fold_buildN() cleanup invalidated
(and fixed) the "REAL_CST" part of the patch.
Some "speculative folding" is now causing false positives, for which there is a
simple fix: suppress warnings when doing such folds. For example

*** tree-ssa-loop-niter.c.orig  Wed Apr 27 13:48:21 2005
--- tree-ssa-loop-niter.c       Wed Apr 27 14:28:59 2005
***************
*** 778,780 ****
--- 778,782 ----
    notcond = invert_truthvalue (cond);
+   inhibit_warnings++;
    e = fold_build2 (TRUTH_OR_EXPR, boolean_type_node, notcond, te);
+   inhibit_warnings--;
    if (nonzero_p (e))

People who think warnings belong only in the front-end might balk.  I could
submit an alternate indirect check for this situation in parser_build_binary_op.
 It would be tidy, but would no longer warn about non-C glitches such as:

libjava/gnu/java/security/x509/X500DistinguishedName.java:447:        if (sep !=
'+' || sep != ',')
libjava/java/net/HttpURLConnection.java:555:    if (((code / 100) != 4) ||
((code / 100) != 5))
libjava/javax/swing/plaf/basic/BasicGraphicsUtils.java:401:    if
((underlinedChar >= 0) || (underlinedChar <= 0xffff))
libjava/javax/security/auth/x500/X500Principal.java:380:        if (sep != '+'
|| sep != ',')

Please let me know if there is any interest in a C-only patch.  (Or any interest
in pursuing this PR.)

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16302


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]