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++ PATCH: Fix PR 13275


Mark Mitchell <mark@codesourcery.com> writes:

| On Wed, 2003-12-17 at 18:04, Gabriel Dos Reis wrote:
| > Mark Mitchell <mark@codesourcery.com> writes:
| > 
| > | On Wed, 2003-12-17 at 16:03, Zack Weinberg wrote:
| > | > Richard Henderson <rth@redhat.com> writes:
| > | > 
| > | > > On Tue, Dec 16, 2003 at 04:46:51PM -0800, Zack Weinberg wrote:
| > | > >> "Objected" is too strong a word.  "Would prefer __builtin_offsetof but
| > | > >> is open to demonstrations that this is too hard" is more accurate.
| > | > >
| > | > > The following patch appears to work for C.  I would recind my
| > | > > earlier claim that it made the grammar too nasty.
| > | > >
| > | > > Given this, does this seem the approach we want to take?
| > | > 
| > | > I like the looks of this but I wonder what the analogous change over
| > | > in the C++ front end is going to look like.
| > | 
| > | The implementation of offsetof I committed meets the requirements
| > | imposed by the C++ standard.  
| > 
| > No, it does not. 
| 
| Why not?

It is an extension that does not implement the requirements imposed by
the C++ standard as evidenced by the examples below.  I could concoct
more, but I think you get the idea. The basic point is that the  work
done by the preprocessor is not the work we're lookinf for.  
If we all agree that we need a built-in (which I think we do), then
let's just forget about CPP.  It isn't the right tool here.  

    #include <stddef.h>

    struct A {
       static int a;
       static A b;
    };

    int A::a;
    A A::b;

    struct B : A {
    };

    int main() {
       offsetof(A, a);              // should be an ERROR
       offsetof(B, A::b);            // ditto
    }


(And the error message in other cases is completely confusing now.
This meets Joseph's point) 

-- Gaby


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