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
Created attachment 11940 [details] original source
Created attachment 11941 [details] preprocessesed source
Created attachment 11942 [details] generated assembly
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.
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.
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.