From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32220 invoked by alias); 13 Oct 2002 15:26:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 32205 invoked by uid 71); 13 Oct 2002 15:26:01 -0000 Date: Sun, 13 Oct 2002 08:26:00 -0000 Message-ID: <20021013152601.32204.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Tim Prince Subject: Re: c++/8209: Failure to detect negative bit-field size (!) Reply-To: Tim Prince X-SW-Source: 2002-10/txt/msg00525.txt.bz2 List-Id: The following reply was made to PR c++/8209; it has been noted by GNATS. From: Tim Prince To: wwieser@gmx.de, gcc-gnats@gcc.gnu.org Cc: Subject: Re: c++/8209: Failure to detect negative bit-field size (!) Date: Sun, 13 Oct 2002 08:18:24 -0700 On Sunday 13 October 2002 02:01, wwieser@gmx.de wrote: > If you compile the following code: > struct A > { > int : (-1); > }; > you get the (correct) _error_ > negative width in bit-field `A::' > > Now, if you compile > struct A > { > int : (sizeof(int)-5); > }; > then you just get the _warning_ > warning: width of `A::' exceeds its type > which is incorrect. > > As a result, sizeof(A) turns out to be 536870912 > (500Mb). > > It looks like your headers might make size_t an unsigned type, but you haven't showed that. Here's what my gcc installation has to say in : /* The ANSI standard suggests that size_t and ptr_diff_t might be */ /* better choices. But those appear to have incorrect definitions */ /* on may systems. Notably "typedef int size_t" seems to be both */ /* frequent and WRONG. */ Maybe the author's failure to check spelling reduces his/her credibility, but you can see there is a documented opinion on this subject. As I read the info page, if you wanted warnings from -Wconversion, should size_t be defined in accordance with the above prejudices, you should get them with sizeof(int) +(-5). -- Tim Prince