public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* RE: How to supress this warning
       [not found] <CFAC7E404509374289CCCDD2E41E09AB01131A@server02.norseld.com>
@ 2003-02-06  8:50 ` Matthias Oltmanns
  0 siblings, 0 replies; only message in thread
From: Matthias Oltmanns @ 2003-02-06  8:50 UTC (permalink / raw)
  To: Rob Curtis, gcc-help, gcc

Hi Rob,

thank you for your reply.


Am Don, 2003-02-06 um 07.10 schrieb Rob Curtis:
> This warning is telling you that 'if( whatever < 0)' will always be
> false therefore why have it. 
> 
> Why would you wan't to suppress this message?
>  
I'am using heavily generic programing concepts. There are some
situations, where i would like to know, if an integer type is signed or
unsigned. E.g.:

template<typename int_type>
class Foo
{
   ...
};

In the context of class Foo i would like to know, if int_type is signed
or not. Normally i could use std::numeric_limits<int_type>::is_signed()
but in my version g++ 2.96 (no, i cannot upgrade to 3.2 :-(  ) these is
not available. Therefor i have
the following template class:

template<typename int_type>
struct IS_SIGNED
{
  enum { RET = (int_type(-1) < 0 ? 1 : 0) }; 
};

With this, i can write ...

template<typename int_type>
class Foo
{
   void blah() {
     if (IS_SIGNED<int_type>::RET) {
        do_left();
     } else {
        do_right();
     }
   }
};

Of course, i could use template specialisation and define IS_SIGNED for
each integer type, but i wonder if it is possible in the way i've
explained.

I'm using -Werror and many warnings enabled. Here is the list:
WARNFLAGS = -W -Wall -Wpointer-arith -Woverloaded-virtual
-Wno-sign-compare -Werror

If i use IS_SIGNED with an instance for an unsigned integer the
comparison evaluates to false, always of course. But thats the nature of
static programming.

So my question again, is it possible to suppress this kind of warning?

Matthias Oltmanns

> Rob Curtis
> 
> 
> -----Original Message-----
> From: Matthias Oltmanns
> [mailto:Mathias.Oltmanns.Oltmanns@sysde.eads.net] 
> Sent: Wednesday, 5 February 2003 8:41 PM
> To: gcc-help@gcc.gnu.org
> Subject: How to supress this warning
> 
> Hi,
> 
> i would like to supress the following warning:
> 
> warning: comparison of unsigned expression < 0
> is always false
> 
> Which of the warning flags is appropriate to supress the warning? GCC
> version is "gcc version 2.96 20000731 (Red hat Linux 7.1 2.96-85)"
> 
> Thanks in advance.
> Matthias
> 
> -- 
> Matthias Oltmanns
> 
> Tel: 04421-1543-274
> mail: Mathias.Oltmanns.Oltmanns@sysde.eads.net
-- 
Matthias Oltmanns

Tel: 04421-1543-274
mail: Mathias.Oltmanns.Oltmanns@sysde.eads.net

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-02-06  8:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CFAC7E404509374289CCCDD2E41E09AB01131A@server02.norseld.com>
2003-02-06  8:50 ` How to supress this warning Matthias Oltmanns

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).