D
dilip ranganathan
Hi
I have taken the liberty to cross-post this. It appeared on c.l.c++.m
but the ICE is regarding VS.NET 7.1 C++ compiler.
post follows:
==============================================
John,
Thank you for the response. We've managed to capture a small snippet
of
code that generates the Internal compiler error. It is as follows:
#include <memory>
class Key { };
class NullKey : public Key { };
class SortList { };
template <typename T> class SortOrder : public SortList {
public:
SortOrder() { }
};
class obj { typedef NullKey KeyType; };
class PersistenceManager {
//public:
// PersistenceManager() { }
public:
template <typename T> void loadSet(const Key &key = NullKey(),
const SortOrder<T>
&sort =
SortOrder<T>());
};
template <typename T>
void PersistenceManager::loadSet(const Key &key,
const SortOrder<T> &sort) {
}
void main() {
PersistenceManager pm;
pm.loadSet<obj>();
}
Beyond this, if the default constructor for PersistenceManager is
uncommented, the INTERNAL COMPILER ERROR disappears and is replaced by
a
standard compiler error, which also does not make sense:
d:\Documents and Settings\mpetter\My
Documents\Projects\test2\test2.cpp(25): error C2440: 'default
argument' :
cannot convert from 'SortOrder<T>' to 'const SortOrder<T> &'
with
[
T=obj
]
If the compiler can convert the NullKey to a const NullKey &, why
can't it
do the same for SortOrder<T>? They are parallel cases, except that
SortOrder is templated.
Furthermore, both the INTERNAL COMPILER ERROR and the conversion error
can
be alleviated by moving the function's implementation inline into the
class
declaration as shown in Figure 2:
Figure 2: Error-free Code:
----------------------------------------------------------------------------------------------------------------------------
#include <memory>
class Key { };
class NullKey : public Key { };
class SortList { };
template <typename T> class SortOrder : public SortList {
public:
SortOrder() { }
};
class obj { typedef NullKey KeyType; };
class PersistenceManager {
//public:
// PersistenceManager() { }
public:
template <typename T> void loadSet(const Key &key = NullKey(),
const SortOrder<T>
&sort =
SortOrder<T>())//;
{ }
};
/*template <typename T>
void PersistenceManager::loadSet(const Key &key,
const SortOrder<T> &sort) {
}*/
void main() {
PersistenceManager pm;
pm.loadSet<obj>();
}
----------------------------------------------------------------------------------------------------------------------------
Any explanations to this erratic behavior are appreciated.
Thanks again.
John
================================================
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
I have taken the liberty to cross-post this. It appeared on c.l.c++.m
but the ICE is regarding VS.NET 7.1 C++ compiler.
post follows:
==============================================
John said:Thus, I suggest you send the smallest example that fails to compile
(or a link to it)
John,
Thank you for the response. We've managed to capture a small snippet
of
code that generates the Internal compiler error. It is as follows:
#include <memory>
class Key { };
class NullKey : public Key { };
class SortList { };
template <typename T> class SortOrder : public SortList {
public:
SortOrder() { }
};
class obj { typedef NullKey KeyType; };
class PersistenceManager {
//public:
// PersistenceManager() { }
public:
template <typename T> void loadSet(const Key &key = NullKey(),
const SortOrder<T>
&sort =
SortOrder<T>());
};
template <typename T>
void PersistenceManager::loadSet(const Key &key,
const SortOrder<T> &sort) {
}
void main() {
PersistenceManager pm;
pm.loadSet<obj>();
}
Beyond this, if the default constructor for PersistenceManager is
uncommented, the INTERNAL COMPILER ERROR disappears and is replaced by
a
standard compiler error, which also does not make sense:
d:\Documents and Settings\mpetter\My
Documents\Projects\test2\test2.cpp(25): error C2440: 'default
argument' :
cannot convert from 'SortOrder<T>' to 'const SortOrder<T> &'
with
[
T=obj
]
If the compiler can convert the NullKey to a const NullKey &, why
can't it
do the same for SortOrder<T>? They are parallel cases, except that
SortOrder is templated.
Furthermore, both the INTERNAL COMPILER ERROR and the conversion error
can
be alleviated by moving the function's implementation inline into the
class
declaration as shown in Figure 2:
Figure 2: Error-free Code:
----------------------------------------------------------------------------------------------------------------------------
#include <memory>
class Key { };
class NullKey : public Key { };
class SortList { };
template <typename T> class SortOrder : public SortList {
public:
SortOrder() { }
};
class obj { typedef NullKey KeyType; };
class PersistenceManager {
//public:
// PersistenceManager() { }
public:
template <typename T> void loadSet(const Key &key = NullKey(),
const SortOrder<T>
&sort =
SortOrder<T>())//;
{ }
};
/*template <typename T>
void PersistenceManager::loadSet(const Key &key,
const SortOrder<T> &sort) {
}*/
void main() {
PersistenceManager pm;
pm.loadSet<obj>();
}
----------------------------------------------------------------------------------------------------------------------------
Any explanations to this erratic behavior are appreciated.
Thanks again.
John
================================================
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]