This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


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

Re: C++ PATCH: Fix PR 288


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


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