Bug 34783 - unwanted limited range warning in template code
Summary: unwanted limited range warning in template code
Status: RESOLVED DUPLICATE of bug 11856
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.2.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-01-14 19:40 UTC by Mike Stump
Modified: 2008-01-14 23:21 UTC (History)
8 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Stump 2008-01-14 19:40:31 UTC
It seems silly for a project to get warnings in the below case.  It seems silly to require that one specialize just to avoid the warning.

$ cat t.cc
void bar();
template <class T>
void foo(T t) {
  if (t < 257) bar();
}

void bee() {
  foo(1);
  foo(char(1));
}
$ g++  t.cc -c
t.cc: In function ‘void foo(T) [with T = char]’:
t.cc:9:   instantiated from here
t.cc:4: warning: comparison is always true due to limited range of data type
Comment 1 Andrew Pinski 2008-01-14 19:42:35 UTC
You know bugzilla has a search for a reason?

*** This bug has been marked as a duplicate of 11856 ***
Comment 2 Mike Stump 2008-01-14 20:08:00 UTC
No, that bug report has a hack around, not a fix.  A fix would make it work by default out of the box.

A fix would avoid these for templated types and leave them for non-templated types.
Comment 3 Andrew Pinski 2008-01-14 21:38:14 UTC
And that bug is not closed yet so what is the issue there?

*** This bug has been marked as a duplicate of 11856 ***
Comment 4 Mike Stump 2008-01-14 23:21:08 UTC
Ah, I thought someone just hadn't gotten around to moving the state to fixed, sorry.