fatal error C1001: INTERNAL COMPILER ERROR

L

LZXIA

Compiling...
overlaod.cpp
d:\vc work\cpp\think_in_cpp\chapter10\overlaod.cpp(17) : fatal error
C1001: INTERNAL COMPILER ERROR
(compiler file 'msc1.cpp', line 1786)
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more
information
Error executing cl.exe.

overlaod.obj - 1 error(s), 0 warning(s)

when compiling, errors above will apear.I am a newbie in C++, I hope
someone here can help me.Following is my source code

#include <iostream>

using namespace std;

class myOverload
{
public:
myOverload(float a, float b)
{
x = a;
y = b;
}
myOverload operator=(const myOverload qq)
{
return myOverload(x = qq.x, y = qq.y);
}
friend const myOverload operator+(const myOverload &m, const
myOverload &n);
void myprint()
{
cout << "here is a complex: \n" << x << "+" << y << "i" << endl;
}
private:
float x;
float y;
};

myOverload const operator+(const myOverload &m, const myOverload &n)
{
return myOverload(m.x + n.x, m.y + n.y);
}

int main()
{
myOverload AA(1.3f, 2.6f);
myOverload BB(1.7f, 0.4f);
myOverload CC = AA + BB;
CC.myprint();

return 0;
}
 
O

osmium

LZXIA said:
Compiling...
overlaod.cpp
d:\vc work\cpp\think_in_cpp\chapter10\overlaod.cpp(17) : fatal error
C1001: INTERNAL COMPILER ERROR
(compiler file 'msc1.cpp', line 1786)
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more
information
Error executing cl.exe.

overlaod.obj - 1 error(s), 0 warning(s)

when compiling, errors above will apear.I am a newbie in C++, I hope
someone here can help me.Following is my source code

#include <iostream>

using namespace std;

class myOverload
{
public:
myOverload(float a, float b)
{
x = a;
y = b;
}
myOverload operator=(const myOverload qq)
{
return myOverload(x = qq.x, y = qq.y);
}
friend const myOverload operator+(const myOverload &m, const
myOverload &n);
void myprint()
{
cout << "here is a complex: \n" << x << "+" << y << "i" << endl;
}
private:
float x;
float y;
};

myOverload const operator+(const myOverload &m, const myOverload &n)
{
return myOverload(m.x + n.x, m.y + n.y);
}

int main()
{
myOverload AA(1.3f, 2.6f);
myOverload BB(1.7f, 0.4f);
myOverload CC = AA + BB;
CC.myprint();

return 0;
}

It compiles and runs OK for me on DevC. Prints 3 + 3i. It looks like your
problem has something to do with VC.

FWIW note that C and C++ programmers rarely use float, they almost always
use double. If they had a huge matrix they might put it in external storage
as a float but re-fluff it when they went to use it. The transcendental
functions and such like work on double.

If I were in your place, I would tuck the problem in the back of my mind and
go on about my business
 
B

benben

LZXIA said:
Compiling...
overlaod.cpp
d:\vc work\cpp\think_in_cpp\chapter10\overlaod.cpp(17) : fatal error
C1001: INTERNAL COMPILER ERROR
(compiler file 'msc1.cpp', line 1786)
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more
information
Error executing cl.exe.

overlaod.obj - 1 error(s), 0 warning(s)

when compiling, errors above will apear.I am a newbie in C++, I hope
someone here can help me.Following is my source code

Internal error usually has nothing to do with your code. Try to compile
a minimum program (ie. int main(){}) and see if the error persist. You
might need to reinstall your compiler.
#include <iostream>

using namespace std;

class myOverload
{
public:
myOverload(float a, float b)
{
x = a;
y = b;
}
myOverload operator=(const myOverload qq)
{
return myOverload(x = qq.x, y = qq.y);
}
friend const myOverload operator+(const myOverload &m, const
myOverload &n);
void myprint()
{
cout << "here is a complex: \n" << x << "+" << y << "i" << endl;
}
private:
float x;
float y;
};

myOverload const operator+(const myOverload &m, const myOverload &n)
{
return myOverload(m.x + n.x, m.y + n.y);
}

int main()
{
myOverload AA(1.3f, 2.6f);
myOverload BB(1.7f, 0.4f);
myOverload CC = AA + BB;
CC.myprint();

return 0;
}

Your code compiled fine with both g++ and cl on my machine.

Regards,
Ben
 
P

pillbug

Compiling...
overlaod.cpp
d:\vc work\cpp\think_in_cpp\chapter10\overlaod.cpp(17) : fatal error
C1001: INTERNAL COMPILER ERROR
(compiler file 'msc1.cpp', line 1786)
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more
information
Error executing cl.exe.

overlaod.obj - 1 error(s), 0 warning(s)

when compiling, errors above will apear.I am a newbie in C++, I hope
someone here can help me.Following is my source code

Your code compiled fine for me with vc6sp5. If you aren't able
to upgrade your compiler, you can at least get the service pack
which should help out some.
 
R

Richard Herring

pillbug said:
Your code compiled fine for me with vc6sp5. If you aren't able
to upgrade your compiler, you can at least get the service pack
which should help out some.

One possible cause of "internal compiler error" with VC++ is the wrong
kind of line separators - which obviously won't show up when other
people cut and paste from a news client to their compilers.

Was any of the code ported from a Unix system?
 
G

Gernot Frisch

One possible cause of "internal compiler error" with VC++ is the
wrong
kind of line separators - which obviously won't show up when other
people cut and paste from a news client to their compilers.

Now that helped me a lot with some old code I could not compile for
some stupid reason. Now it works, thanks a lot!
 
D

David Welch

it probably doesn't like the friend function or the odd const, try this:

#include <iostream>

using namespace std;

class myOverload
{
public:
myOverload(float a, float b)
{
x = a;
y = b;
}
myOverload operator=(const myOverload & qq) //<<
{
return myOverload(x = qq.x, y = qq.y);
}
friend const myOverload operator+(const myOverload &m,
const myOverload &n);
void myprint()
{
cout << "here is a complex: \n" << x << "+" << y << "i"
<< endl;
}
private:
float x;
float y;
};

// or here with the odd const
myOverload /* const */ operator+(const myOverload &m, const myOverload &n)
{
return myOverload(m.x + n.x, m.y + n.y);
}

int main()
{
myOverload AA(1.3f, 2.6f);
myOverload BB(1.7f, 0.4f);
myOverload CC = AA + BB;
CC.myprint();

return 0;
}
 
M

Michiel.Salters

LZXIA said:
I think there must be some probelm in my VC6.0. Thanks.

Probably. Ask in their groups, get a (free?) upgrade, and finally,
check
if your disk is full. VC6 chokes on that (it's not the only one, but
it's
rather unhelpful about it)

HTH
Michiel Salters
 
R

RKS

Try cleaning your project. I have had this problem many times before.
Most of the times, cleaning the project and other dependecies fixes it.
Clean Rebuild All.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top