This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/2402: Problem with compile-time sizeof evaluation and templates
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c++/2402: Problem with compile-time sizeof evaluation and templates
- From: stephen at bregmasoft dot com
- Date: 27 Mar 2001 13:40:08 -0000
- Reply-To: stephen at bregmasoft dot com
>Number: 2402
>Category: c++
>Synopsis: Problem with compile-time sizeof evaluation and templates
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Tue Mar 27 05:46:03 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: stephen@bregmasoft.com
>Release: GNU C++ version 3.1 20010326 (experimental) (i686-pc-linux-gnu)
>Organization:
>Environment:
>Description:
The following well-formed C++ program
// -- begin tu.cpp --
template< class T >
struct C
{
static T returnaT();
enum { itsSize = sizeof C::returnaT() };
};
int
main(int argc, char* argv[])
{
long aSize = C<double>::itsSize;
return 0;
}
// -- end tu.cpp -
gives the following error on compile (g++ tu.cpp):
tu.cpp: In instantiation of `C<double>':
tu.cpp:13: instantiated from here
tu.cpp:13: no method `C<double>::returnaT'
Note that (a) there is too a C<double>::returnaT, since it's defined
in the previous line, and (2) it's not Smalltalk, there are no "methods,"
only member functions, so the error message text could be improved
to say what it means.
The problem only occurs with templated classes. The same code using a non-templated class
compiles OK.
There's a large body of standard-compliant code out there that
relies on this sort of construct working.
This code has never worked with any version of GCC, so it's not a regression.
>How-To-Repeat:
See description above.
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: