• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Bug in g++'s int constructor?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug in g++'s int constructor?


  • Subject: Re: Bug in g++'s int constructor?
  • From: Phillip Morelock <email@hidden>
  • Date: Thu, 28 Mar 2002 16:42:38 -0800

now maybe i'm being stupid, but

why don't u just
int sum = 0;

??
cheers
fillup


On 3/28/02 2:42 PM, "Mark" <email@hidden> wrote:

> Hi everyone,
>
> Please excuse me if this is off topic for this list, I really didn't
> know where else to post it, aside for maybe darwin-dev or whatnot.
> I believe I have inadvertently discovered a bug in g++. ( 2.95 I
> believe, stock OS 10.1.3 with most recent dev tools installed )
> The int constructor is only initializing an int to 0 in a member
> function on the first run of that function. All calls to that function,
> after the initial, get the SAME value that the int had when running the
> member function the first time through.
>
> i.e. this is what happened to me...
> On the first run insert works perfectly, next time its called sum was
> reallocated in the same spot with the same value every time. So the
> program would hang, insert would never return true (ITEM was inserted)
> because the sum of everything in the array + ITEM would ALWAYS be
> greater then CAPACITY.
>
> bool bag::insert( const int ITEM )
> {
> int sum;
>
> for( x = 0; x <= ARRAY_INDEX; x++ )
> {
> sum += data[x];
> }
>
> if( (sum + ITEM) <= CAPACITY )
> {
> data[ ARRAY_INDEX ] = ITEM;
> ARRAY_INDEX++;
> return ( true );
> }
> else
> return ( false );
> }
>
> Granted just changing int sum; to int sum = 0; fixes the problem, but
> doesn't change the fact that this is a bug.
> To the point, has anyone else discovered this? Filled a bug report?
> Should I?
>
> thanks for your time,
> - Mark.
> _______________________________________________
> cocoa-dev mailing list | email@hidden
> Help/Unsubscribe/Archives:
> http://www.lists.apple.com/mailman/listinfo/cocoa-dev
> Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Bug in g++'s int constructor?
      • From: Mark <email@hidden>
References: 
 >Bug in g++'s int constructor? (From: Mark <email@hidden>)

  • Prev by Date: Re: coco on windows
  • Next by Date: Re: What's a malloc_zone_calloc error?
  • Previous by thread: Bug in g++'s int constructor?
  • Next by thread: Re: Bug in g++'s int constructor?
  • Index(es):
    • Date
    • Thread