473,806 Members | 2,782 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Nasty Bug: First exception error.

I have a class that has a std::list of ints as a member. Let's say its
this:

std::list<int> MyInts;

Frequently, another list of ints is assigned to MyInts

MyInts = MyOtherInts;

This occasionally gives me a "First-chance exception" error. I haven't
a clue what this is or why it is happening. The problem is in the
following lines of STL code:

_Myt& operator=(const _Myt& _X)
{if (this != &_X)
{iterator _F1 = begin();
iterator _L1 = end();
const_iterator _F2 = _X.begin();
const_iterator _L2 = _X.end();
for (; _F1 != _L1 && _F2 != _L2; ++_F1, ++_F2)
//here---> *_F1 = *_F2;
erase(_F1, _L1);
insert(_L1, _F2, _L2); }

This is the worst bug I've ever had and i just don't know where to
start with fixing it. I would appreciate any advice you guys have to
offer.
Jul 22 '05 #1
4 1281
On Tue, 16 Dec 2003 19:09:26 +0530, tarmat <ta****@btopenw orld.com> wrote:
I have a class that has a std::list of ints as a member. Let's say its
this:

std::list<in t> MyInts;

Frequently, another list of ints is assigned to MyInts

MyInts = MyOtherInts;

This occasionally gives me a "First-chance exception" error. I haven't
a clue what this is or why it is happening. The problem is in the
following lines of STL code:

_Myt& operator=(const _Myt& _X)
{if (this != &_X)
{iterator _F1 = begin();
iterator _L1 = end();
const_iterator _F2 = _X.begin();
const_iterator _L2 = _X.end();
for (; _F1 != _L1 && _F2 != _L2; ++_F1, ++_F2)
//here---> *_F1 = *_F2;
erase(_F1, _L1);
insert(_L1, _F2, _L2); }

This is the worst bug I've ever had and i just don't know where to
start with fixing it. I would appreciate any advice you guys have to
offer.


Generally a "first-chance" exception is benign; you'll get that wherever
an exception is thrown.

However you shouldn't get any exception from the assignment shown.

Best advice: post a _small_, complete program that exhibits the problem.

Jul 22 '05 #2
> _Myt& operator=(const _Myt& _X)
{if (this != &_X)
{iterator _F1 = begin();
iterator _L1 = end();
const_iterator _F2 = _X.begin();
const_iterator _L2 = _X.end();
for (; _F1 != _L1 && _F2 != _L2; ++_F1, ++_F2)
//here---> *_F1 = *_F2;
erase(_F1, _L1);
insert(_L1, _F2, _L2); }


Maybe not && but ||. It seems that F2 reaches end, but F1 does not.

for (; _F1 != _L1 || _F2 != _L2; ++_F1, ++_F2)

I'm not sure about this.
Jul 22 '05 #3
In article <t1************ *************** *****@4ax.com>,
ta****@btopenwo rld.com says...
I have a class that has a std::list of ints as a member. Let's say its
this:

std::list<int> MyInts;

Frequently, another list of ints is assigned to MyInts

MyInts = MyOtherInts;

This occasionally gives me a "First-chance exception" error.


A first-chance exception is NOT an error. If you don't see a second-
chance exception, it means that the exception has been handled, and it's
not an error at all.

It looks like in this case the system has paged out some of the memory
in your list. When you try to read from or write to the memory that's
not present in physical memory, the CPU raises an exception. The OS
then handles that by reading the correct data into memory.

--
Later,
Jerry.

The universe is a figment of its own imagination.
Jul 22 '05 #4
Marko Becirevic wrote:
_Myt& operator=(const _Myt& _X)
{if (this != &_X)
{iterator _F1 = begin();
iterator _L1 = end();
const_iterator _F2 = _X.begin();
const_iterator _L2 = _X.end();
for (; _F1 != _L1 && _F2 != _L2; ++_F1, ++_F2)
//here---> *_F1 = *_F2;
erase(_F1, _L1);
insert(_L1, _F2, _L2); }


Maybe not && but ||. It seems that F2 reaches end, but F1 does not.

for (; _F1 != _L1 || _F2 != _L2; ++_F1, ++_F2)

I'm not sure about this.


&& is correct. The symptoms of memory-related errors often occur far
from the code that actually caused the problem. They're only rarely
caused by code in the standard library.

--

Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
Jul 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
1978
by: Andrew Baker | last post by:
If you have every had the following error when trying to use load a form in the IDE then read on!!! An exception occurred while trying to create an instance of GSL.Windows.Forms.BrowserFormBase. The exception was "Method Validate in type GSL.Shared.GridFilters.GridFilter from assembly GSL.Shared, Version=1.0.1804.21512, Culture=neutral, PublicKeyToken=null does not have an implementation.".
19
1821
by: Jerry | last post by:
I managed to narrow this down to a very simple expression. try this: private void Bug() { bool b = false; Test(3, (b || b) && b && !b); } private void Works() {
1
3851
by: Dejan Vesic | last post by:
I found nasty "documentation" bug; ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfsystemglobalizationcultureinfoclasstopic.htm claims that proper culture info name for Serbian (Cyrillic) - Serbia is "Cy-sr-SP" but if you try this, you will get "Culture name Cy-sr-SP is not supported" exception. If you set up culture info via System.Globalization.CultureInfo(0x081A) and than retrieve
16
1741
by: Edward Diener | last post by:
After spending more than a day reducing a complicated compiler bug to a simple case I reported it to the MSDN Product Feedback Center as a bug just now. However this bug is completely stymying my development of a VC++ component. Does Microsoft still offer any free bug reporting cases for VS2005, as they did two for VS2003 so that I can talk with a technical representative directly to try to find a workaround for the compiler bug ? While...
6
8207
by: S Wheeler | last post by:
I have a REALLY nasty problem and could use some expert help. I have two mixed mode apps. Each uses a mixed mode DLL that exports a couple of classes. There is no dll main as it is not needed. This was working fine until a couple of days ago when I added some (a lot of) new code to the dll. The apps generally do not run at the same time. Every thing compiles and links OK. But at run time I now immediately get : The application failed...
16
1731
by: marc_r_bertrand | last post by:
To all asp/db pros: The quiz code below works. But there is a problem when too many questions are answered (radio buttons clicked). I am not an asp pro. So, is there a pro out there or an amateur guru who will be so kind as to volunteer some time to figure out where the bug is? This may mean he will have to go through the tedious steps of creating an .mdb with a few records...unless the bug is obvious... On a page with server-code...
0
1991
by: Kurt B. Kaiser | last post by:
Patch / Bug Summary ___________________ Patches : 385 open (+21) / 3790 closed (+21) / 4175 total (+42) Bugs : 1029 open (+43) / 6744 closed (+43) / 7773 total (+86) RFE : 262 open ( +4) / 291 closed ( +4) / 553 total ( +8) New / Reopened Patches ______________________
1
1779
by: spamtrap | last post by:
Hy; I've got a nasty variation of the Guillotine-bug on a three-column layout, sadly the variations of the Holly-hack I tried to apply don't work: http://centroamericajoven.org/estudios-y-publicaciones/publicaciones.html I have it tested on IE6 inside a VirtualPC, on Windows 98. It appears only if the IE-Window is smaller than the center-rectangle (which when
0
9719
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10623
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10373
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10111
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7650
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5683
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4330
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3010
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.