This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/11856] New: Wrong warning regarding assert


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

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

           Summary: Wrong warning regarding assert
           Product: gcc
           Version: 3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: o dot kullmann at swansea dot ac dot uk
                CC: gcc-bugs at gcc dot gnu dot org

<file AssertWarning.cpp> 
---------------------------------------- 
#include <cassert> 
void f(unsigned char c) { 
  assert(0 <= c and c <= 2); 
} 
int main() { 
  f(5); 
} 
---------------------------------------- 
yields: 
> g++ AssertWarning.cpp 
AssertWarning.cpp: In function `void f(unsigned char)': 
AssertWarning.cpp:3: warning: comparison is always true due to limited range 
of data type 
 
which is wrong: Running it yields (as it should be): 
> ./a.out 
a.out: AssertWarning.cpp:3: void f(unsigned char): Assertion `0 <= c and c <= 
2' failed. 
Aborted. 
 
Tested Versions: 3.3 and 3.2.1 (same behaviour). 
(Platform: Linux (Suse 8.0)) 
 
I'm writing a generic library, and this warning shows up all over the 
place, and since the warning messages typically are *very* long (due 
to the deeply nested template names), the output of g++ is rendered 
unreadable. 
 
Since it doesn't seem to be possible to inhibit this warning message (!), 
the only work around is to use 
 
g++ -w 
 
inhibiting *all* warnings.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]