public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* An optimization bug in egcs 1.0.2?
@ 1998-03-23 15:11 H.J. Lu
  1998-03-23 19:24 ` John Carr
  0 siblings, 1 reply; 7+ messages in thread
From: H.J. Lu @ 1998-03-23 15:11 UTC (permalink / raw)
  To: egcs

Hi,

While compiling glibc 2.0.7 with egcs 1.0.2, I noticed that egcs 1.0.2
turns

if (imap->l_global)
  {
   /* This object is in the global scope list.  Remove it.  */
   struct link_map **tail = _dl_global_scope_end;
   do
     --tail;
    while (*tail != imap);
    --_dl_global_scope_end;
    memcpy (tail, tail + 1,
      (void *) _dl_global_scope_end -  (void *) tail);
    _dl_global_scope_end[0] = NULL;
    _dl_global_scope_end[1] = NULL;
  }

into

if (imap->l_global)
  {
   /* This object is in the global scope list.  Remove it.  */
   struct link_map **tail = _dl_global_scope_end;
   do
     --tail;
    while (*tail != imap);
    --_dl_global_scope_end;
    _dl_global_scope_end[0] = NULL;
    _dl_global_scope_end[1] = NULL;
    memcpy (tail, tail + 1,
      (void *) _dl_global_scope_end -  (void *) tail);
    _dl_global_scope_end[1] = NULL;
  }

when I use -O2 -fPIC. As the result, the resuling binary doesn't work
since _dl_global_scope_end[0] is within (void *) tail + 1 and 
(void *) tail + 1 + (void *) _dl_global_scope_end -  (void *) tail.
Is that normal for a C compiler to do it?

BTW, I changed it to

if (imap->l_global)
  {
   /* This object is in the global scope list.  Remove it.  */
   struct link_map **tail = _dl_global_scope_end;
   do
     --tail;
    while (*tail != imap);
    memcpy (tail, tail + 1,
      (void *) _dl_global_scope_end -  (void *) tail);
    --_dl_global_scope_end;
  }

since _dl_global_scope_end [0] and _dl_global_scope_end [1] are
always NULL to begin with. It works fine for me.

Thanks.


-- 
H.J. Lu (hjl@gnu.org)

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~1998-03-24 11:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-03-23 15:11 An optimization bug in egcs 1.0.2? H.J. Lu
1998-03-23 19:24 ` John Carr
1998-03-23 19:24   ` H.J. Lu
1998-03-23 23:47     ` Jeffrey A Law
1998-03-24 11:16     ` Richard Henderson
1998-03-24  8:29       ` H.J. Lu
1998-03-24  9:27       ` H.J. Lu

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).