public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: Wolfgang Bangerth <bangerth@ticam.utexas.edu> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, Subject: Re: c++/9881: Incorrect address calculation for static class member Date: Thu, 27 Feb 2003 23:16:00 -0000 [thread overview] Message-ID: <20030227231601.26043.qmail@sources.redhat.com> (raw) The following reply was made to PR c++/9881; it has been noted by GNATS. From: Wolfgang Bangerth <bangerth@ticam.utexas.edu> To: "Peter A. Buhr" <pabuhr@plg2.math.uwaterloo.ca> Cc: asharji@uwaterloo.ca, <gcc-bugs@gcc.gnu.org>, <gcc-gnats@gcc.gnu.org> Subject: Re: c++/9881: Incorrect address calculation for static class member Date: Thu, 27 Feb 2003 17:09:09 -0600 (CST) > bar v; > double *module::b = &(((bar *)(&v))->p); // LINE X > //double *module::b = &(((bar *)(&module::storage))->p); // LINE Y > > If you run this with gcc3.3, the output is: > > @awk[5]% a.out > 0x8049a50 0x8049a48 > > Now comment out LINE X, and uncomment LINE Y and run again getting output: > > @awk[6]% a.out > 0x8049a78 0 > > Zero (0) is not an acceptable address. Well, zero is the value the standard prescribes of initial initialization, i.e. before dynamic initializers are run. > BUT, the only different between these 2 > lines is the chunk of storage for the object. Notice this has nothing to do > with the constructor. One case works and one doesn't. Is this not compelling? Well, all the questions you raise boil down to the question: what is an address constant expression. Apparently, the compiler chooses to consider the initializer in line X to be one, while it doesn't for line Y. I cannot answer the question further than what I did in my previous mail, apart from the fact that line X has not cast (or, rather: a cast from one type to itself), while line Y has a (reinterpret_)cast from type module to incompatible type bar. Just as an aside, independent of the validity of the PR in itself: why are you making it so particularly hard for the compiler to decide this? You are setting module::b to &module::storage; there is simple syntax to achieve this goal than teh one you use, no? :-) Cheers W. ------------------------------------------------------------------------- Wolfgang Bangerth email: bangerth@ticam.utexas.edu www: http://www.ticam.utexas.edu/~bangerth/
next reply other threads:[~2003-02-27 23:16 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2003-02-27 23:16 Wolfgang Bangerth [this message] -- strict thread matches above, loose matches on Subject: below -- 2003-03-02 22:16 Wolfgang Bangerth 2003-02-28 13:56 Peter A. Buhr 2003-02-27 22:56 Peter A. Buhr 2003-02-27 22:06 Wolfgang Bangerth 2003-02-27 21:46 Peter A. Buhr 2003-02-27 21:40 bangerth 2003-02-27 18:22 bangerth 2003-02-27 18:06 asharji
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=20030227231601.26043.qmail@sources.redhat.com \ --to=bangerth@ticam.utexas.edu \ --cc=gcc-prs@gcc.gnu.org \ --cc=nobody@gcc.gnu.org \ /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: linkBe 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).