Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com Message-ID: <023701c16403$dfa81a60$6501a8c0@dns.rcn.net> Reply-To: "Robert Allan Schwartz" From: "Robert Allan Schwartz" To: Subject: g++ 2.95.3-5 - Templates bug? Date: Fri, 2 Nov 2001 20:07:08 -0500 Organization: Tessellation Training MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700 I adapted some code from Andrei Alexandrescu's Loki class library: // start of code: #include using namespace std; template class Conversion { public: #ifdef ONE template class ConversionHelper { public: typedef char Small; struct Big { char dummy[2]; }; static Big Test(...); static Small Test(U1); static T1 MakeT(); }; typedef ConversionHelper H; enum { exists = sizeof(typename H::Small) == sizeof(H::Test(H::MakeT())) }; #endif #ifdef TWO typedef char Small; struct Big { char dummy[2]; }; static Big Test(...); static Small Test(U); static T MakeT(); enum { exists = sizeof( Small) == sizeof( Test( MakeT())) }; #endif enum { exists2Way = exists && Conversion::exists }; enum { sameType = false }; }; template class Conversion { public: enum { exists = 1, exists2Way = 1,sameType = 1 }; }; int main() { cout << Conversion::exists; return 0; } // end of code I'm using g++ version 2.95.3-5. If I compile -DONE, it compiles and executes OK. If I compile -DTWO, it gets the following errors: andrei.cpp: In instantiation of `Conversion': andrei.cpp:44: instantiated from here andrei.cpp:44: invalid use of undefined type `class Conversion' andrei.cpp:33: forward declaration of `class Conversion' andrei.cpp:44: invalid use of undefined type `class Conversion' andrei.cpp:33: forward declaration of `class Conversion' andrei.cpp: In instantiation of `Conversion': andrei.cpp:44: instantiated from `Conversion' andrei.cpp:44: instantiated from here andrei.cpp:44: invalid use of undefined type `class Conversion' andrei.cpp:33: forward declaration of `class Conversion' andrei.cpp:44: invalid use of undefined type `class Conversion' andrei.cpp:33: forward declaration of `class Conversion' I don't understand why replacing the ConversionHelper with its members causes the errors. Is this a bug? Robert Schwartz -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/