This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


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

1.3.3: g++ misinterprets an instantiation of a template class


Here is the test case:

#include <iostream>

using namespace std;

// general case:

template <bool /* unnamed */>
class static_checker; // declaration, not definition.

// special case:

template <>
class static_checker<true>
{
 // definition.
};

int main(void)
{
 static_checker<sizeof(int) == 4> sizeof_int_checker; // line 20.

 static_checker<sizeof(char) == 4> sizeof_char_checker; // line 22.

 return 0;
}

I expect an error on line 22, as static_checker<false> is declared but
not defined, but instead I get these errors:

sample036.cpp: In function `int main()':
sample036.cpp:20: `sizeof_int_checker' undeclared (first use this
function)
sample036.cpp:20: (Each undeclared identifier is reported only once
sample036.cpp:20: for each function it appears in.)
sample036.cpp:20: parse error before `;'
sample036.cpp:22: `sizeof_char_checker' undeclared (first use this
function)
sample036.cpp:22: parse error before `;'

MSVC 6.0 and Metrowerks CodeWarrior 2.0 get this right.

Thanks for your help,

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/


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