public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/11492] Unsigned char promoted to signed int in for loop test for gpp but not gcc
       [not found] <bug-11492-6488@http.gcc.gnu.org/bugzilla/>
@ 2005-11-15 16:19 ` pinskia at gcc dot gnu dot org
  2007-01-22  8:28 ` manu at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-11-15 16:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from pinskia at gcc dot gnu dot org  2005-11-15 16:19 -------
(In reply to comment #1)
> "1000" is a signed integer constant, so b*1000 is a signed integer too. I
> guess the warning is ok, then.

That is only true for unsigned multiplication and signed when overflow is
undefined (-fno-wrapv which is default for C and C++).

The reason why this is middle-end and not C is because tree_expr_nonnegative_p
is part of the middle-end and not part of the C front-end.  Fixing
tree_expr_nonnegative_p will also provide some optimization opertunites also.


-- 


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


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

* [Bug middle-end/11492] Unsigned char promoted to signed int in for loop test for gpp but not gcc
       [not found] <bug-11492-6488@http.gcc.gnu.org/bugzilla/>
  2005-11-15 16:19 ` [Bug middle-end/11492] Unsigned char promoted to signed int in for loop test for gpp but not gcc pinskia at gcc dot gnu dot org
@ 2007-01-22  8:28 ` manu at gcc dot gnu dot org
  2008-10-29 17:17 ` [Bug middle-end/11492] Bogus warning with -Wsign-compare manu at gcc dot gnu dot org
  2008-10-29 17:24 ` manu at gcc dot gnu dot org
  3 siblings, 0 replies; 6+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-01-22  8:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from manu at gcc dot gnu dot org  2007-01-22 08:28 -------
(In reply to comment #5)
> (In reply to comment #1)
> > "1000" is a signed integer constant, so b*1000 is a signed integer too. I
> > guess the warning is ok, then.
> 
> That is only true for unsigned multiplication and signed when overflow is
> undefined (-fno-wrapv which is default for C and C++).
> 

But in the example shown, it is true always, since b == 2 at compile time.
Can't we detect that? I know that there is no dataflow solving in the
front-ends. But as you said, tree_expr_nonnegative_p is part of the middle-end.
Perhaps we should have dataflow info at the front-end. It will make our
warnings much smarter.


-- 


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


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

* [Bug middle-end/11492] Bogus warning with -Wsign-compare
       [not found] <bug-11492-6488@http.gcc.gnu.org/bugzilla/>
  2005-11-15 16:19 ` [Bug middle-end/11492] Unsigned char promoted to signed int in for loop test for gpp but not gcc pinskia at gcc dot gnu dot org
  2007-01-22  8:28 ` manu at gcc dot gnu dot org
@ 2008-10-29 17:17 ` manu at gcc dot gnu dot org
  2008-10-29 17:24 ` manu at gcc dot gnu dot org
  3 siblings, 0 replies; 6+ messages in thread
From: manu at gcc dot gnu dot org @ 2008-10-29 17:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from manu at gcc dot gnu dot org  2008-10-29 17:17 -------
Subject: Bug 11492

Author: manu
Date: Wed Oct 29 17:16:46 2008
New Revision: 141434

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=141434
Log:
2008-10-29  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

        PR 11492
        * c-common.c (min_precision): Move to...
        * tree.c (tree_int_cst_min_precision): ... to here. Renamed.
        * tree.h (tree_int_cst_min_precision): Declare.
        * c-common.h (min_precision): Delete declaration.
        * fold-const.c (tree_binary_nonnegative_warnv_p): Handle
        multiplication of non-negative integer constants.
        * c-decl.c (check_bitfield_type_and_width): Rename min_precision to
        tree_int_cst_min_precision.
        (finish_enum): Likewise.
cp/
        * class.c (check_bitfield_decl): Rename min_precision to
        tree_int_cst_min_precision.
        * decl.c (finish_enum): Likewise.
testsuite/
        * gcc.dg/pr11492.c: New.
        * g++.dg/warn/pr11492.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/warn/pr11492.C
    trunk/gcc/testsuite/gcc.dg/pr11492.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-common.c
    trunk/gcc/c-common.h
    trunk/gcc/c-decl.c
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/class.c
    trunk/gcc/cp/decl.c
    trunk/gcc/fold-const.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree.c
    trunk/gcc/tree.h


-- 


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


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

* [Bug middle-end/11492] Bogus warning with -Wsign-compare
       [not found] <bug-11492-6488@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2008-10-29 17:17 ` [Bug middle-end/11492] Bogus warning with -Wsign-compare manu at gcc dot gnu dot org
@ 2008-10-29 17:24 ` manu at gcc dot gnu dot org
  3 siblings, 0 replies; 6+ messages in thread
From: manu at gcc dot gnu dot org @ 2008-10-29 17:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from manu at gcc dot gnu dot org  2008-10-29 17:24 -------
FIXED in GCC 4.4. Thanks for the report and sorry for the time this took!


-- 

manu at gcc dot gnu dot org changed:

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


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


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

* [Bug middle-end/11492] Unsigned char promoted to signed int in for loop test for gpp but not gcc
  2003-07-10 19:28 [Bug c++/11492] New: Unsigned char promoted to signed int in for loop test for gpp but not gcc afonso at contronics dot com dot br
  2003-07-29 16:21 ` [Bug middle-end/11492] " pinskia at physics dot uc dot edu
@ 2003-08-23  0:46 ` dhazeghi at yahoo dot com
  1 sibling, 0 replies; 6+ messages in thread
From: dhazeghi at yahoo dot com @ 2003-08-23  0:46 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


dhazeghi at yahoo dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  GCC build triplet|i586-pc-msdosdjgpp          |
   GCC host triplet|i586-pc-msdosdjgpp          |
 GCC target triplet|*-*-*                       |
   Target Milestone|3.4                         |---


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

* [Bug middle-end/11492] Unsigned char promoted to signed int in for loop test for gpp but not gcc
  2003-07-10 19:28 [Bug c++/11492] New: Unsigned char promoted to signed int in for loop test for gpp but not gcc afonso at contronics dot com dot br
@ 2003-07-29 16:21 ` pinskia at physics dot uc dot edu
  2003-08-23  0:46 ` dhazeghi at yahoo dot com
  1 sibling, 0 replies; 6+ messages in thread
From: pinskia at physics dot uc dot edu @ 2003-07-29 16:21 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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


pinskia at physics dot uc dot edu changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c++                         |middle-end
 GCC target triplet|i586-pc-msdosdjgpp          |*-*-*
   Last reconfirmed|2003-07-10 21:12:40         |2003-07-29 16:21:48
               date|                            |


------- Additional Comments From pinskia at physics dot uc dot edu  2003-07-29 16:21 -------
It also happens in c and in powerpc-apple-darwin6.6.


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

end of thread, other threads:[~2008-10-29 17:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-11492-6488@http.gcc.gnu.org/bugzilla/>
2005-11-15 16:19 ` [Bug middle-end/11492] Unsigned char promoted to signed int in for loop test for gpp but not gcc pinskia at gcc dot gnu dot org
2007-01-22  8:28 ` manu at gcc dot gnu dot org
2008-10-29 17:17 ` [Bug middle-end/11492] Bogus warning with -Wsign-compare manu at gcc dot gnu dot org
2008-10-29 17:24 ` manu at gcc dot gnu dot org
2003-07-10 19:28 [Bug c++/11492] New: Unsigned char promoted to signed int in for loop test for gpp but not gcc afonso at contronics dot com dot br
2003-07-29 16:21 ` [Bug middle-end/11492] " pinskia at physics dot uc dot edu
2003-08-23  0:46 ` dhazeghi at yahoo dot com

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).