public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/8209: Failure to detect negative bit-field size (!)
@ 2002-10-13  2:06 wwieser
  0 siblings, 0 replies; 3+ messages in thread
From: wwieser @ 2002-10-13  2:06 UTC (permalink / raw)
  To: gcc-gnats


>Number:         8209
>Category:       c++
>Synopsis:       Failure to detect negative bit-field size (!)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          accepts-illegal
>Submitter-Id:   net
>Arrival-Date:   Sun Oct 13 02:06:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     wwieser@gmx.de
>Release:        3.2.1 20021007 (prerelease) and many more
>Organization:
>Environment:
linux-elf
>Description:
The bug was verified to be still present in yesterday's
CVS (Oct 12): 

If you compile the following code: 
  struct A
  {
      int : (-1);
  };
you get the (correct) _error_ 
  negative width in bit-field `A::<anonymous>'

Now, if you compile
  struct A
  {
    int : (sizeof(int)-5);
  };
then you just get the _warning_
warning: width of `A::<anonymous>' exceeds its type
which is incorrect. 

As a result, sizeof(A) turns out to be 536870912
(500Mb). 
>How-To-Repeat:
Just compile the four-liner above. 
>Fix:
Should be fairly trivial, but I don't know. 
>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: c++/8209: Failure to detect negative bit-field size (!)
@ 2002-10-13  8:26 Tim Prince
  0 siblings, 0 replies; 3+ messages in thread
From: Tim Prince @ 2002-10-13  8:26 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/8209; it has been noted by GNATS.

From: Tim Prince <tprince@computer.org>
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::<anonymous>'
 >
 > Now, if you compile
 >   struct A
 >   {
 >     int : (sizeof(int)-5);
 >   };
 > then you just get the _warning_
 > warning: width of `A::<anonymous>' 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 <gc.h>:
 /* 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: c++/8209: Failure to detect negative bit-field size (!)
@ 2002-10-13  2:57 nathan
  0 siblings, 0 replies; 3+ messages in thread
From: nathan @ 2002-10-13  2:57 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, wwieser

Synopsis: Failure to detect negative bit-field size (!)

State-Changed-From-To: open->closed
State-Changed-By: nathan
State-Changed-When: Sun Oct 13 02:57:42 2002
State-Changed-Why:
    not a bug. sizeof (int) -5 has unsigned type.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8209


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-10-13 15:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-13  2:06 c++/8209: Failure to detect negative bit-field size (!) wwieser
2002-10-13  2:57 nathan
2002-10-13  8:26 Tim Prince

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).