Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > terminate called after throwing an instance of 'std::bad_alloc'

Reply
Thread Tools

terminate called after throwing an instance of 'std::bad_alloc'

 
 
Frederick Gotham
Guest
Posts: n/a
 
      11-07-2006
Bill Medland:

> Compiles fine on mine!


Because that's the code your compiling, as opposed to the source code of the
compiler.

--

Frederick Gotham
 
Reply With Quote
 
 
 
 
Daniel T.
Guest
Posts: n/a
 
      11-07-2006
"mlimber" <(E-Mail Removed)> wrote:

> Frederick Gotham wrote:
> > but I don't see how a
> > bug could result in the throwing of a bad_alloc.

>
> int main()
> {
> for( ;; ) int *p = new int;
> }


That won't cause the *compiler* to throw a bad_alloc.

--
To send me email, put "sheltie" in the subject.
 
Reply With Quote
 
 
 
 
Frederick Gotham
Guest
Posts: n/a
 
      11-07-2006
Daniel T.:

> That won't cause the *compiler* to throw a bad_alloc.



It will if it's part of the compiler's source code.

--

Frederick Gotham
 
Reply With Quote
 
Jim Langston
Guest
Posts: n/a
 
      11-08-2006
"Mohsen" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> Hello everyone,
>
> In my program, I have to define many pointers and when I want to
> compile my program (in UNIX), it gives me the following error:
>
> terminate called after throwing an instance of 'std::bad_alloc'
> what(): St9bad_alloc
> Abort
>
> I rechecked those pointers; I found I cannot decrease the size of them.
> Any idea how I can to solve this problem?
>
> Thanks,
> Mohsen


You say it's happening when you are tryign to compile, not run your program.
The first thing I would do would attempt to get a newer version of the
compiler. If that didnt' work, I would google for my compiler name and
"bad_alloc" and see if I got any hits. If that didnt' work I"d post in a
newsgroup for my compiler.


 
Reply With Quote
 
Nate Barney
Guest
Posts: n/a
 
      11-08-2006
Jim Langston wrote:
> "Mohsen" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) oups.com...
>> Hello everyone,
>>
>> In my program, I have to define many pointers and when I want to
>> compile my program (in UNIX), it gives me the following error:
>>
>> terminate called after throwing an instance of 'std::bad_alloc'
>> what(): St9bad_alloc
>> Abort
>>
>> I rechecked those pointers; I found I cannot decrease the size of them.
>> Any idea how I can to solve this problem?
>>
>> Thanks,
>> Mohsen

>
> You say it's happening when you are tryign to compile, not run your program.
> The first thing I would do would attempt to get a newer version of the
> compiler. If that didnt' work, I would google for my compiler name and
> "bad_alloc" and see if I got any hits. If that didnt' work I"d post in a
> newsgroup for my compiler.
>


What does the standard say about recursive templates? For instance, g++
3.4.4 issues a reasonable diagnostic with the following, but is it
required to? Seems like this could be something that might cause a
compiler to throw std::bad_alloc.

template <unsigned long N>
class A
{
public:

static const unsigned long a = A<N+1>::a;
};

int main()
{
unsigned long i = A<0>::a;
}

Nate
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: terminate called after throwing an instance of 'CABRTException' Daniel Fetchinson Python 0 10-02-2012 12:06 PM
Re: terminate called after throwing an instance of 'CABRTException' Peter Otten Python 0 10-02-2012 10:54 AM
terminate called after throwing an instance of 'CABRTException' Daniel Fetchinson Python 0 10-02-2012 09:45 AM
exception problem with cygwin - terminate called recursively Philipp Kraus C++ 7 07-16-2011 11:17 PM
TypeError: unbound method PrintInput() must be called with test instance as first argument (got test instance instead) arotem Python 4 10-17-2005 07:52 AM



Advertisments