This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C++ PATCH: Fix PR 288
- To: gcc-patches at gcc dot gnu dot org
- Subject: Re: C++ PATCH: Fix PR 288
- From: Doug Gregor <gregod at cs dot rpi dot edu>
- Date: Sun, 18 Feb 2001 01:14:27 -0500
- Organization: RPI
- References: <20010217215922T.mitchell@codesourcery.com>
- Reply-To: gregod at cs dot rpi dot edu
On Sunday 18 February 2001 12:59, Mark Mitchell wrote:
> It's unclear whether this code
>
> struct S
> {
> int i;
> __typeof( S::i ) f ();
> };
>
> should be considered legal. On the one hand, you could argue that
> S::i has type `int'. However, in most places, you can't talk about
> the type of a non-static data member without an object. Once again,
> we see the problem with language extensions...
This isn't a problem specific to the typeof extension, however. Consider a
similar code snippet with the same problem:
struct S {
int i;
static const int s = sizeof(S::i);
};
In general, the typeof extension need not be semantically different from
sizeof, but is many times more useful. See
http://gcc.gnu.org/ml/gcc-patches/2001-01/msg01755.html
for an example of typeof usage that would greatly simplify template
metaprogramming.
Doug Gregor
gregod@cs.rpi.edu