This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/22505] New: cast of enum causes invalid template instanciation instead of cast to int.


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]