Board index » cppbuilder » Internal code generator error F1001

Internal code generator error F1001


2006-05-26 11:40:10 PM
cppbuilder27
I've posted the details to QC as report 29421. Basically, I have a
templatized mathematical vector class which I've had forever and which has
compiled under Borland 5, Microsoft 6/.NET, and Gnu. The BDS compiler
throws an internal code generator error when I include it in any project.
Between this and the number of IDE crashes I've seen (more in three months
with BDS than in 5 years with BCB 5) I'm starting to think that, for the
first time EVER, Microsoft has a superior product on the market and that
Borland has dropped the ball. Considering that my first task on a PC was to
compile a Turbo Pascal program in 1983 for a college class, and I've owned
at least one version of every Pascal/C++/Delphi offering the company has
ever made, it would be a sad day indeed.
 
 

Re:Internal code generator error F1001

"Bob Beauchaine" < XXXX@XXXXX.COM >wrote in message
Quote
I've posted the details to QC as report 29421. Basically, I have a
templatized mathematical vector class which I've had forever and which has
It seems that your problem is caused by combination of friend
declaration and overloads for this function
Here's a short piece of code that demonstrates the problem
template<typename T>
struct A
{
friend void f( A<T>const& );
T g()const;
};
template<typename T>
void f( A<T>const& V )
{
V.g();
}
void f( A<double>const& V )
{
V.g();
}
Compiler gives [C++ Fatal Error] Unit1.cpp(20): F1001 Internal code
generator error
( 'f' here corresponds to std::ostream& operator<<( std::ostream&, Vector<T>
const&)
in your code)
Actually the friend here does not do what is probaly was intended,
it guarantees friendship only to non-template functions, and you
probably want the friendship for template function too.
The correct (IMHO) way to do that is to declare all template
and non-template functions you want to make friends before
the template class and use :: before the function name in
friend declaration
template<typename T>struct A;
template<typename T>void f( A<T>const& V );
void f( A<double>const& V );
template<typename T>
struct A
{
friend void ::f( A<T>const& );
T g()const;
};
template<typename T>
void f( A<T>const& V )
{
V.g();
}
void f( A<double>const& V )
{
V.g();
}
Cheers,
Serge
 

Re:Internal code generator error F1001

Thanks for catching this, Serge. This code is old, and predates the modern
friendship declaration syntax of which I'm aware, but of course who bothers
to go back and retrofit working code until it breaks the compiler?
I would have been inclined to do the following. Instead of
template<typename T>struct A;
template<typename T>void f( A<T>const& V );
void f( A<double>const& V );
template<typename T>
struct A
{
friend void ::f( A<T>const& );
T g()const;
};
I prefer the simpler
template<typename T>
struct A
{
friend void f( A<T>const& )
{
//body of f;
}
T g()const;
};
Which gives me the covarying version of f() (which is the only version I
really need) without the forward declarations. It's been a while so my
memory is unclear, but I believe that I had multiple versions of f() in my
code because of poor support for member templates in previous versions of
the compiler (or other compilers of less capabilty).
Thanks again for hunting down the cause.
 

{smallsort}