public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: Richard C Bilson <rcbilson@plg2.math.uwaterloo.ca>
To: nobody@gcc.gnu.org
Cc: gcc-prs@gcc.gnu.org,
Subject: Re: c++/9881: What is an address constant expression?
Date: Fri, 07 Mar 2003 19:36:00 -0000	[thread overview]
Message-ID: <20030307193601.1178.qmail@sources.redhat.com> (raw)

The following reply was made to PR c++/9881; it has been noted by GNATS.

From: Richard C Bilson <rcbilson@plg2.math.uwaterloo.ca>
To: nathan@codesourcery.com
Cc: bangerth@ticam.utexas.edu, gcc-bugs@gcc.gnu.org, gcc-gnats@gcc.gnu.org,
        pabuhr@uwaterloo.ca
Subject: Re: c++/9881: What is an address constant expression?
Date: Fri, 7 Mar 2003 14:31:03 -0500 (EST)

 > From nathan@codesourcery.com  Fri Mar  7 11:25:42 2003
 > Richard C Bilson wrote:
 > 
 > > This is why I believe that the old behavior of gcc was not in error,
 > > regardless of how 5.19.4 is interpreted.
 > and neither is the new behaviour. This is a missed optimization
 > opportunity. My changes were to prevent a miscompilation on
 > sparc and other strict aligned architectures.
 
 Whether the new behavior is in error is a matter of debate it seems.
 I think that 5.19.4 requires the initializer in question to be an
 address constant expression and thus be a static initialization.
 Wolfgang Bangerth has provided a different interpretation -- I don't
 agree with his interpretation, but I'll grant that it's a hard question
 and it doesn't fall to me to decide the answer.
 
 On the other hand, I am capable of proposing a solution, so I will.
 My intent is to restore the old behavior, at least for the expression
 in question.
 
 To fix the offsetof bug, you added some code to fold the address
 calculation in the case that a) the operand of the address is a
 COMPONENT_REF, b) the first operand of the component is an INDIRECT_REF,
 and c) the operand of the indirection is an integer constant.  In other
 words, you're looking for &(((T*)0)->x).  If this expression can be
 computed as a constant, I see no reason why it couldn't be computed as a
 constant if the null pointer is replaced with a pointer to static data --
 this is exactly the case that's causing us problems.
 
 As far as I can tell, the code to handle &(((T*)0)->x) also works
 just fine in the case that the pointer is not null.  So I removed the
 restriction that the operand of the indirection be a NPC.
 
 This fixes our example code, solves the real problem that prompted us to
 complain in the first place, and doesn't seem to cause any trouble with
 the gcc test suite.  I can't say whether it would cause a recurrence
 of the problems you fixed in the first place, but I do have some SPARC
 machines at my disposal if you have an example of the problem for me
 to try.
 
 Many thanks to you and to Wolfgang for taking the time to correspond with
 us on this matter.
 
 - Richard
 
 [ This diff is against the version of cp/typeck.c in the cvs 3.3 branch
 from Monday.  I've been trying to update for a couple of days now, but I
 keep getting "connection reset by peer" from subversions. ]
 
 *** typeck-orig.c       Fri Mar  7 13:44:51 2003
 --- typeck.c    Fri Mar  7 13:47:53 2003
 *************** build_unary_op (code, xarg, noconvert)
 *** 4300,4308 ****
             return error_mark_node;
           }
         else if (TREE_CODE (arg) == COMPONENT_REF
 !                && TREE_CODE (TREE_OPERAND (arg, 0)) == INDIRECT_REF
 !                && (TREE_CODE (TREE_OPERAND (TREE_OPERAND (arg, 0), 0))
 !                    == INTEGER_CST))
           {
             /* offsetof idiom, fold it.  */
             tree field = TREE_OPERAND (arg, 1);
 --- 4300,4306 ----
             return error_mark_node;
           }
         else if (TREE_CODE (arg) == COMPONENT_REF
 !                && TREE_CODE (TREE_OPERAND (arg, 0)) == INDIRECT_REF)
           {
             /* offsetof idiom, fold it.  */
             tree field = TREE_OPERAND (arg, 1);
 
 


             reply	other threads:[~2003-03-07 19:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-03-07 19:36 Richard C Bilson [this message]
  -- strict thread matches above, loose matches on Subject: below --
2003-04-21 11:30 nathan
2003-04-08 18:39 nathan
2003-03-10 20:36 Richard C Bilson
2003-03-08 14:16 Nathan Sidwell
2003-03-07 16:26 Nathan Sidwell
2003-03-07 14:56 Richard C Bilson
2003-03-06 23:06 Wolfgang Bangerth
2003-03-06 22:46 Richard C Bilson
2003-03-05 22:10 bangerth

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=20030307193601.1178.qmail@sources.redhat.com \
    --to=rcbilson@plg2.math.uwaterloo.ca \
    --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: 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).