User account creation filtered due to spam.

Bug 22505 - cast of enum causes invalid template instanciation instead of cast to int.
Summary: cast of enum causes invalid template instanciation instead of cast to int.
Status: RESOLVED DUPLICATE of bug 21514
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2005-07-15 19:44 UTC by Shelby Noonan
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host: i686-pc-linux
Target: i686-pc-linux
Build: i686-pc-linux
Known to work:
Known to fail:
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description Shelby Noonan 2005-07-15 19:44:03 UTC
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 ----
Comment 1 Andrew Pinski 2005-07-15 19:48:21 UTC
This is a dup of bug 21514,  the standard ambiguous about this problem.

*** This bug has been marked as a duplicate of 21514 ***