public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Gabriel Dos Reis <gdr@integrable-solutions.net>
To: Arnold Cole <y09kpa@yahoo.com>
Cc: gcc@gcc.gnu.org
Subject: Re: invalid offsetof from non-POD type
Date: Fri, 12 Sep 2003 04:55:00 -0000	[thread overview]
Message-ID: <m3d6e6wtcy.fsf@uniton.integrable-solutions.net> (raw)
In-Reply-To: <20030912032850.99020.qmail@web60201.mail.yahoo.com>

Arnold Cole <y09kpa@yahoo.com> writes:

|                                       In my mind,
| offsetof stands just on the same level as sizeof.

sizeof applies uniformly to all data type.

offsetof operates at a different level: that of datatypes with no
nearly no abstraction layer.

[...]

| #define offsetof(cls,member) (((size_t)&((cls
| *)0x100->member)-0x100)

it seems you have your own idea of what offsetof should mean for a
non-POD class.  That idea does not agree with mine.  For example,
given the above implementation of offsetof, what does it return for

   #include <iostream>
   struct A {
     int& r;
     A(int& i) : r(i) { }
   };

   int main()
   {
      std::cout << offset(A, r) << std::endl;
   }

on my machine (i686-pc-linux-gnu) I get a SIGSEV.

What about
 
    struct B  {
      enum { E = offset (A, r) };
    };

?

leave alone polymorphic classes.

[...]

| If any of the standard gurus out there would care to
| explain to me why offsetof shouldn't work for non POD
| types (and what POD types are), I'd appreciate it.

the issue has been hashed here and there in the past.

Anyway, it has been raised in the C++ standards committee.

-- Gaby

  reply	other threads:[~2003-09-12  3:58 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-12  4:32 Arnold Cole
2003-09-12  4:55 ` Gabriel Dos Reis [this message]
  -- strict thread matches above, loose matches on Subject: below --
2003-08-12 13:38 skaller
2003-08-12 14:36 ` Fergus Henderson
2003-08-12 22:05   ` skaller
2003-08-13 20:59     ` Matt Austern
2003-08-14  8:20       ` skaller
2003-04-21 13:49 John Quigley
2003-04-21 14:30 ` Gabriel Dos Reis
2003-04-22  2:40   ` John Quigley
2003-04-22  3:14     ` Gabriel Dos Reis
2003-04-22  4:49       ` Zack Weinberg
2003-04-22  6:32         ` Gabriel Dos Reis
2003-04-22 10:09           ` Kai Henningsen
2003-04-22 10:34             ` Gabriel Dos Reis
2003-04-22 10:50               ` Nathan Sidwell
2003-04-22 10:59                 ` Gabriel Dos Reis
2003-04-22 18:19                   ` Zack Weinberg
2003-04-22 19:35                     ` Joe Buck
2003-04-22 11:07                 ` Gabriel Dos Reis
2003-04-22 18:46                   ` Joe Buck
2003-04-22 18:37           ` Joe Buck
2003-04-22 19:24             ` Daniel Jacobowitz
2003-04-22 19:39               ` Joe Buck
2003-04-23  7:38               ` Gabriel Dos Reis
2003-04-23  7:42                 ` Gareth Pearce
2003-04-22  7:06       ` John Quigley
2003-04-22  8:51         ` Gabriel Dos Reis
2003-04-25  8:07           ` John Quigley
2003-04-25 12:14             ` Nathan Sidwell
2003-04-25 12:29               ` Gareth Pearce
2003-04-25 15:13               ` Paul Koning
2003-04-25 23:30             ` Matthias Benkmann
2003-04-26 14:42               ` Nathan Sidwell
2003-04-27 15:43                 ` Matthias Benkmann
2003-04-28 18:59                   ` Matt Austern
2003-04-21 14:50 ` Nathan Sidwell
2003-01-10  7:28 Chris Croswhite

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=m3d6e6wtcy.fsf@uniton.integrable-solutions.net \
    --to=gdr@integrable-solutions.net \
    --cc=gcc@gcc.gnu.org \
    --cc=y09kpa@yahoo.com \
    /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).