public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: stephen@bregmasoft.com
To: gcc-gnats@gcc.gnu.org
Subject: c++/2402: Problem with compile-time sizeof evaluation and templates
Date: Tue, 27 Mar 2001 05:46:00 -0000	[thread overview]
Message-ID: <20010327134008.2008.qmail@sourceware.cygnus.com> (raw)

>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:


             reply	other threads:[~2001-03-27  5:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-27  5:46 stephen [this message]
2002-11-01  6:44 lerdsuwa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010327134008.2008.qmail@sourceware.cygnus.com \
    --to=stephen@bregmasoft.com \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).