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]
Other format: [Raw text]

Re: [c++] fold offsetof by hand


Richard Henderson wrote:

On Sun, Aug 29, 2004 at 12:24:43PM -0700, Mark Mitchell wrote:

You should be checking whether or not the expression is dependent, not whether or not we are in a template. Otherwise, we'll get various subtle semantics wrong.


Example?

This should be accepted:


struct S { int i; };

template <unsigned int I> struct A;
template <> struct A<0> { typedef int T; };

template <typename T>
void f() {
  A<offsetof (S, i)>::T x
}

It will not be accepted if the compiler cannot figure out what the offset is. Since S is not dependent, the compiler is supposed to figure that out.

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com


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