public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/28488]  New: incorrect warning says signed and unsigned type in conditional expression
@ 2006-07-26  3:41 gurganbl at rose-hulman dot edu
  2006-07-26  3:41 ` [Bug c/28488] " gurganbl at rose-hulman dot edu
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: gurganbl at rose-hulman dot edu @ 2006-07-26  3:41 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2859 bytes --]

This warning indicates a signed/unsigned comparison, but there is no
signed/unsigned comparison that I can see.

gurganbl@gurganbl ~ $ gcc -v -save-temps -Wall -Wextra -Werror
conditional-sign-mismatch-bug.c
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: /var/tmp/portage/gcc-4.1.1/work/gcc-4.1.1/configure
--prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/4.1.1
--includedir=/usr/lib/gcc/i686-pc-linux-gnu/4.1.1/include
--datadir=/usr/share/gcc-data/i686-pc-linux-gnu/4.1.1
--mandir=/usr/share/gcc-data/i686-pc-linux-gnu/4.1.1/man
--infodir=/usr/share/gcc-data/i686-pc-linux-gnu/4.1.1/info
--with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/4.1.1/include/g++-v4
--host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --disable-altivec
--enable-nls --without-included-gettext --with-system-zlib --disable-checking
--disable-werror --disable-libunwind-exceptions --disable-multilib
--disable-libmudflap --disable-libssp --disable-libgcj --enable-languages=c,c++
--enable-shared --enable-threads=posix --enable-__cxa_atexit
--enable-clocale=gnu
Thread model: posix
gcc version 4.1.1 (Gentoo 4.1.1)
 /usr/libexec/gcc/i686-pc-linux-gnu/4.1.1/cc1 -E -quiet -v
conditional-sign-mismatch-bug.c -mtune=pentiumpro -Wall -Wextra -Werror
-fpch-preprocess -o conditional-sign-mismatch-bug.i
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory
"/usr/lib/gcc/i686-pc-linux-gnu/4.1.1/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/i686-pc-linux-gnu/4.1.1/include
 /usr/include
End of search list.
 /usr/libexec/gcc/i686-pc-linux-gnu/4.1.1/cc1 -fpreprocessed
conditional-sign-mismatch-bug.i -quiet -dumpbase
conditional-sign-mismatch-bug.c -mtune=pentiumpro -auxbase
conditional-sign-mismatch-bug -Wall -Wextra -Werror -version -o
conditional-sign-mismatch-bug.s
GNU C version 4.1.1 (Gentoo 4.1.1) (i686-pc-linux-gnu)
        compiled by GNU C version 4.1.1 (Gentoo 4.1.1).
GGC heuristics: --param ggc-min-expand=99 --param ggc-min-heapsize=129574
Compiler executable checksum: 33e66c7a45cdf50541c0a56896affe02
cc1: warnings being treated as errors
conditional-sign-mismatch-bug.c: In function ‘main’:
conditional-sign-mismatch-bug.c:13: warning: signed and unsigned type in
conditional expression


-- 
           Summary: incorrect warning says signed and unsigned type in
                    conditional expression
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gurganbl at rose-hulman dot edu
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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

* [Bug c/28488] incorrect warning says signed and unsigned type in conditional expression
  2006-07-26  3:41 [Bug c/28488] New: incorrect warning says signed and unsigned type in conditional expression gurganbl at rose-hulman dot edu
@ 2006-07-26  3:41 ` gurganbl at rose-hulman dot edu
  2006-07-26  3:42 ` gurganbl at rose-hulman dot edu
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: gurganbl at rose-hulman dot edu @ 2006-07-26  3:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from gurganbl at rose-hulman dot edu  2006-07-26 03:41 -------
Created an attachment (id=11940)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=11940&action=view)
original source


-- 


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


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

* [Bug c/28488] incorrect warning says signed and unsigned type in conditional expression
  2006-07-26  3:41 [Bug c/28488] New: incorrect warning says signed and unsigned type in conditional expression gurganbl at rose-hulman dot edu
  2006-07-26  3:41 ` [Bug c/28488] " gurganbl at rose-hulman dot edu
@ 2006-07-26  3:42 ` gurganbl at rose-hulman dot edu
  2006-07-26  3:43 ` gurganbl at rose-hulman dot edu
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: gurganbl at rose-hulman dot edu @ 2006-07-26  3:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from gurganbl at rose-hulman dot edu  2006-07-26 03:42 -------
Created an attachment (id=11941)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=11941&action=view)
preprocessesed source


-- 


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


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

* [Bug c/28488] incorrect warning says signed and unsigned type in conditional expression
  2006-07-26  3:41 [Bug c/28488] New: incorrect warning says signed and unsigned type in conditional expression gurganbl at rose-hulman dot edu
  2006-07-26  3:41 ` [Bug c/28488] " gurganbl at rose-hulman dot edu
  2006-07-26  3:42 ` gurganbl at rose-hulman dot edu
@ 2006-07-26  3:43 ` gurganbl at rose-hulman dot edu
  2006-07-26  8:03 ` rguenth at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: gurganbl at rose-hulman dot edu @ 2006-07-26  3:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from gurganbl at rose-hulman dot edu  2006-07-26 03:43 -------
Created an attachment (id=11942)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=11942&action=view)
generated assembly


-- 


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


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

* [Bug c/28488] incorrect warning says signed and unsigned type in conditional expression
  2006-07-26  3:41 [Bug c/28488] New: incorrect warning says signed and unsigned type in conditional expression gurganbl at rose-hulman dot edu
                   ` (2 preceding siblings ...)
  2006-07-26  3:43 ` gurganbl at rose-hulman dot edu
@ 2006-07-26  8:03 ` rguenth at gcc dot gnu dot org
  2006-07-26 11:42 ` gurganbl at rose-hulman dot edu
  2006-07-26 11:47 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2006-07-26  8:03 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from rguenth at gcc dot gnu dot org  2006-07-26 08:03 -------
It says "warning: signed and unsigned type in conditional expression" and that
is the case:

        unsigned int found_len = 0 ? a - b : foo;

because a - b is signed and foo is unsigned.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


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

* [Bug c/28488] incorrect warning says signed and unsigned type in conditional expression
  2006-07-26  3:41 [Bug c/28488] New: incorrect warning says signed and unsigned type in conditional expression gurganbl at rose-hulman dot edu
                   ` (3 preceding siblings ...)
  2006-07-26  8:03 ` rguenth at gcc dot gnu dot org
@ 2006-07-26 11:42 ` gurganbl at rose-hulman dot edu
  2006-07-26 11:47 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: gurganbl at rose-hulman dot edu @ 2006-07-26 11:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from gurganbl at rose-hulman dot edu  2006-07-26 11:42 -------
That would be a problem in assignment, not in the conditional. Additionally, if
I do unsigned int baz = 0;
signed int bar = -1;
baz = bar;

I get no warning. I agree with what you say about there being a problem and
what the problem is, but it should give the same warning as for the above code.
Currently, the ?: syntax gives a misleading warning since the problem is not in
the conditional but in the assignment and strictly having the assignment
problem is not generating a warning.


-- 

gurganbl at rose-hulman dot edu changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |


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


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

* [Bug c/28488] incorrect warning says signed and unsigned type in conditional expression
  2006-07-26  3:41 [Bug c/28488] New: incorrect warning says signed and unsigned type in conditional expression gurganbl at rose-hulman dot edu
                   ` (4 preceding siblings ...)
  2006-07-26 11:42 ` gurganbl at rose-hulman dot edu
@ 2006-07-26 11:47 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-07-26 11:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pinskia at gcc dot gnu dot org  2006-07-26 11:47 -------
No, you are incorrect.  Anyways the warnings about ?: are to make sure that you
know that they are different signedness, which might change the behavior
slightly than what you are expecting.
unsigned int baz = 0;
signed int bar = -1;
baz = bar;

This is a different issue and I think is being fixed by the -Wcoercion work.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


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

end of thread, other threads:[~2006-07-26 11:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-26  3:41 [Bug c/28488] New: incorrect warning says signed and unsigned type in conditional expression gurganbl at rose-hulman dot edu
2006-07-26  3:41 ` [Bug c/28488] " gurganbl at rose-hulman dot edu
2006-07-26  3:42 ` gurganbl at rose-hulman dot edu
2006-07-26  3:43 ` gurganbl at rose-hulman dot edu
2006-07-26  8:03 ` rguenth at gcc dot gnu dot org
2006-07-26 11:42 ` gurganbl at rose-hulman dot edu
2006-07-26 11:47 ` pinskia at gcc dot gnu dot 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).