https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66622
Bug ID: 66622 Summary: -Wsign-conversion does not take advantage of data flow analysis Product: gcc Version: 5.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: john.marshall at sanger dot ac.uk Target Milestone: --- With GCC 5.1 built from gcc-5.1.0.tar.bz2 on OS X: Target: x86_64-apple-darwin13.4.0 Configured with: ../gcc-5.1.0/configure --prefix=... --enable-languages=c,c++,fortran Thread model: posix gcc version 5.1.0 (GCC) The following C program compiled with -Wsign-conversion produces a warning: unsigned foo(int i) { if (i < 0) return 0; else return i; } $ gcc-5.1 -c -Wsign-conversion valueconv.c valueconv.c: In function ‘foo’: valueconv.c:3:15: warning: conversion to ‘unsigned int’ from ‘int’ may change the sign of the result [-Wsign-conversion] else return i; However if the compiler took advantage of the fact that i>=0 within the else, it would realise the warning was a false positive.