This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/22505] New: cast of enum causes invalid template instanciation instead of cast to int.
- From: "snoonan at nvidia dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 15 Jul 2005 19:44:04 -0000
- Subject: [Bug c++/22505] New: cast of enum causes invalid template instanciation instead of cast to int.
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The following code produces an error (below) when compiled with gcc 4.0.0. The
correct code (the enum is cast to an int) is produced with 3.4.3 . There seems
to be no reason to try the template, and even if there is, why is this template
not dismissed from consideration instead of producing an error.
bug.cpp: In function 'void Fn()':
bug.cpp:17: error: 'Fn()::<anonymous enum>' is/uses anonymous type
bug.cpp:17: error: trying to instantiate 'template<class T> template<class A>
Derived::Derived(const A&)'
---- cut bug.cpp -----
template <typename V, typename T, int N>
struct Base {
friend bool operator < (const V &a, const V &b) { return true; }
};
template <typename T>
struct Derived: public Base<Derived<T>, T, 3> {
template <typename A> Derived(const A &a): Base<Derived, T, 3>(a) {}
};
class Extra
{
Derived<double> v;
};
void Fn(void )
{
enum { kConst = 8 };
int idx = 4;
if( idx < kConst );
}
---- end bug.cpp ----
--
Summary: cast of enum causes invalid template instanciation
instead of cast to int.
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: snoonan at nvidia dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux
GCC host triplet: i686-pc-linux
GCC target triplet: i686-pc-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22505