Re: -Wextra and unsigned template parameters

2006-05-10 Thread Joe Buck
On Wed, May 10, 2006 at 12:30:33PM -0400, Andrew Pinski wrote: > > I think that the warning is useful if the comparison is *always* true for > > any call of foo. But here, whether the test is redundant or not > > depends on the type of bar. Possibly there's a way to determine that the > > type of

Re: -Wextra and unsigned template parameters

2006-05-10 Thread lopezibanez
On 10/05/06, Joe Buck <[EMAIL PROTECTED]> wrote: But then I just thought of another case: template struct foo { foo(const Container& bar) { if (bar.size() >= 0) use(bar); } }; For any STL-compliant container the test is redundant. But if we put in a rule saying to suppress the warning if

Re: -Wextra and unsigned template parameters

2006-05-10 Thread Andrew Pinski
> > > Aliesha Finkel <[EMAIL PROTECTED]> writes: > > | Hi, I'm using -Wextra (-W) to compile my code, one > > | feature of which is throwing a warning when an > > | unsigned type is checked for >= 0 since it's always > > | true. In general I find this to be very helpful, but > > | it throws this

Re: -Wextra and unsigned template parameters

2006-05-10 Thread Gabriel Dos Reis
Joe Buck <[EMAIL PROTECTED]> writes: [...] | class C { | public: | int size() const; many people, including "dinosaure" C++ users, wish the standard containers did not have unsigned return type for size(). -- Gaby

Re: -Wextra and unsigned template parameters

2006-05-10 Thread Gabriel Dos Reis
Joe Buck <[EMAIL PROTECTED]> writes: | Aliesha Finkel <[EMAIL PROTECTED]> writes: | > | Hi, I'm using -Wextra (-W) to compile my code, one | > | feature of which is throwing a warning when an | > | unsigned type is checked for >= 0 since it's always | > | true. In general I find this to be very h

Re: -Wextra and unsigned template parameters

2006-05-10 Thread Joe Buck
Aliesha Finkel <[EMAIL PROTECTED]> writes: > | Hi, I'm using -Wextra (-W) to compile my code, one > | feature of which is throwing a warning when an > | unsigned type is checked for >= 0 since it's always > | true. In general I find this to be very helpful, but > | it throws this error even for t

Re: -Wextra and unsigned template parameters

2006-05-10 Thread Gabriel Dos Reis
Aliesha Finkel <[EMAIL PROTECTED]> writes: | Hi, I'm using -Wextra (-W) to compile my code, one | feature of which is throwing a warning when an | unsigned type is checked for >= 0 since it's always | true. In general I find this to be very helpful, but | it throws this error even for templated t

Re: -Wextra and unsigned template parameters

2006-05-10 Thread lopezibanez
On 10/05/06, Aliesha Finkel <[EMAIL PROTECTED]> wrote: template struct foo { foo(T bar) { if (bar >= 0) bar = 1; } }; If foo is instantiated elsewhere then this check could still be useful. My opinion is that since it may be instantiated as an signed type, then warning is pointless there.

-Wextra and unsigned template parameters

2006-05-09 Thread Aliesha Finkel
Hi, I'm using -Wextra (-W) to compile my code, one feature of which is throwing a warning when an unsigned type is checked for >= 0 since it's always true. In general I find this to be very helpful, but it throws this error even for templated types. A code example is included below. Does anyone