public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/67863] New: -Wtautological-compare warns when it shouldn't
@ 2015-10-06 10:22 mpolacek at gcc dot gnu.org
  2015-10-06 10:22 ` [Bug c++/67863] " mpolacek at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2015-10-06 10:22 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67863

            Bug ID: 67863
           Summary: -Wtautological-compare warns when it shouldn't
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mpolacek at gcc dot gnu.org
  Target Milestone: ---

extern int e;
#define A (e ? 4 : 8)
#define B (e ? 4 : 8)

int
fn (void)
{
  if (A <= B)
    return 1;
  return 0;
}

cc1plus warns, while cc1 does not.  What happens here is that the COND_EXPRs
warn_tautological_cmp gets don't have a location in cc1plus:

(gdb) pt
warning: Expression is not an assignment (and might have no effect)
 <cond_expr 0x7ffff16fa990
    type <integer_type 0x7ffff16ff7e0 int public SI
        size <integer_cst 0x7ffff171d0a8 constant 32>
        unit size <integer_cst 0x7ffff171d0c0 constant 4>
        align 32 symtab 0 alias set -1 canonical type 0x7ffff16ff7e0 precision
32 min <integer_cst 0x7ffff171d060 -2147483648> max <integer_cst 0x7ffff171d078
2147483647>
        pointer_to_this <pointer_type 0x7ffff1721930>>

    arg 0 <ne_expr 0x7ffff1853cd0
        type <boolean_type 0x7ffff16ffd20 bool public unsigned QI
            size <integer_cst 0x7ffff16fbf48 constant 8>
            unit size <integer_cst 0x7ffff16fbf60 constant 1>
            align 8 symtab 0 alias set -1 canonical type 0x7ffff16ffd20
precision 1 min <integer_cst 0x7ffff171d1b0 0> max <integer_cst 0x7ffff171d1e0
1>>

        arg 0 <var_decl 0x7ffff1707bd0 e type <integer_type 0x7ffff16ff7e0 int>
            used public external decl_2 SI file b.c line 1 col 12 size
<integer_cst 0x7ffff171d0a8 32> unit size <integer_cst 0x7ffff171d0c0 4>
            align 32 context <translation_unit_decl 0x7ffff7ff91e0 D.1> chain
<function_decl 0x7ffff1854c40 __cxa_call_unexpected>>
        arg 1 <integer_cst 0x7ffff171d1f8 constant 0>>
    arg 1 <integer_cst 0x7ffff171d588 type <integer_type 0x7ffff16ff7e0 int>
constant 4>
    arg 2 <integer_cst 0x7ffff186ac30 type <integer_type 0x7ffff16ff7e0 int>
constant 8>>

in cc1:

(gdb) pt
warning: Expression is not an assignment (and might have no effect)
 <cond_expr 0x7ffff1828b70
    type <integer_type 0x7ffff16ff7e0 int public SI
        size <integer_cst 0x7ffff16fbee8 constant 32>
        unit size <integer_cst 0x7ffff16fbf00 constant 4>
        align 32 symtab 0 alias set -1 canonical type 0x7ffff16ff7e0 precision
32 min <integer_cst 0x7ffff16fbea0 -2147483648> max <integer_cst 0x7ffff16fbeb8
2147483647>
        pointer_to_this <pointer_type 0x7ffff1719930>>

    arg 0 <ne_expr 0x7ffff182b050 type <integer_type 0x7ffff16ff7e0 int>

        arg 0 <c_maybe_const_expr 0x7ffff182b028 type <integer_type
0x7ffff16ff7e0 int>
            arg 1 <var_decl 0x7ffff1707c60 e>>
        arg 1 <integer_cst 0x7ffff1718048 constant 0>
        b.c:8:7>
    arg 1 <integer_cst 0x7ffff1718330 type <integer_type 0x7ffff16ff7e0 int>
constant 4>
    arg 2 <integer_cst 0x7ffff18191e0 type <integer_type 0x7ffff16ff7e0 int>
constant 8>
    b.c:8:7>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/67863] -Wtautological-compare warns when it shouldn't
  2015-10-06 10:22 [Bug c++/67863] New: -Wtautological-compare warns when it shouldn't mpolacek at gcc dot gnu.org
@ 2015-10-06 10:22 ` mpolacek at gcc dot gnu.org
  2015-10-06 10:23 ` mpolacek at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2015-10-06 10:22 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67863

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
   Target Milestone|---                         |6.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/67863] -Wtautological-compare warns when it shouldn't
  2015-10-06 10:22 [Bug c++/67863] New: -Wtautological-compare warns when it shouldn't mpolacek at gcc dot gnu.org
  2015-10-06 10:22 ` [Bug c++/67863] " mpolacek at gcc dot gnu.org
@ 2015-10-06 10:23 ` mpolacek at gcc dot gnu.org
  2015-10-06 13:14 ` mpolacek at gcc dot gnu.org
  2015-10-06 17:57 ` mpolacek at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2015-10-06 10:23 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67863

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-10-06
     Ever confirmed|0                           |1

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
And because of the missing location in cc1plus this
 1911   /* Don't warn for various macro expansions.  */
 1912   if (from_macro_expansion_at (loc)
 1913       || from_macro_expansion_at (EXPR_LOCATION (lhs))
 1914       || from_macro_expansion_at (EXPR_LOCATION (rhs)))
 1915     return;
doesn't trigger so we warn.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/67863] -Wtautological-compare warns when it shouldn't
  2015-10-06 10:22 [Bug c++/67863] New: -Wtautological-compare warns when it shouldn't mpolacek at gcc dot gnu.org
  2015-10-06 10:22 ` [Bug c++/67863] " mpolacek at gcc dot gnu.org
  2015-10-06 10:23 ` mpolacek at gcc dot gnu.org
@ 2015-10-06 13:14 ` mpolacek at gcc dot gnu.org
  2015-10-06 17:57 ` mpolacek at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2015-10-06 13:14 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67863

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |mpolacek at gcc dot gnu.org

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I think I have a fix.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/67863] -Wtautological-compare warns when it shouldn't
  2015-10-06 10:22 [Bug c++/67863] New: -Wtautological-compare warns when it shouldn't mpolacek at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2015-10-06 13:14 ` mpolacek at gcc dot gnu.org
@ 2015-10-06 17:57 ` mpolacek at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2015-10-06 17:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67863

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed for GCC 6.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-10-06 17:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-06 10:22 [Bug c++/67863] New: -Wtautological-compare warns when it shouldn't mpolacek at gcc dot gnu.org
2015-10-06 10:22 ` [Bug c++/67863] " mpolacek at gcc dot gnu.org
2015-10-06 10:23 ` mpolacek at gcc dot gnu.org
2015-10-06 13:14 ` mpolacek at gcc dot gnu.org
2015-10-06 17:57 ` mpolacek at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).