public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/37889]  New: SEGV, conditional execution proactively executed the false arm.
@ 2008-10-22  2:26 hp at gcc dot gnu dot org
  2008-10-22  2:27 ` [Bug middle-end/37889] " hp at gcc dot gnu dot org
                   ` (24 more replies)
  0 siblings, 25 replies; 26+ messages in thread
From: hp at gcc dot gnu dot org @ 2008-10-22  2:26 UTC (permalink / raw)
  To: gcc-bugs

The following executable testcase, reduced from the CRIS port of an old
3.2.x-based version of gcc, is miscompiled at -O2 with
"gcc-4_3-branch revision 141262" and
"trunk revision 141281" configured with --prefix=/usr --enable-languages=c
--with-cpu=generic.  When run, it catches a SEGV.  It is known to work with at
least the Fedora "gcc-4.1.2-33" release.

gcc.c-torture/execute/prNNNNN-1.c:
int flag_pic;
const char * reg_names[(16 + 1 + 1 + 1)] = {"x", "y", "z"};
extern void abort (void) __attribute__ ((__noreturn__));
extern void exit (int) __attribute__ ((__noreturn__));
void __attribute__ ((__noinline__)) asm_fprintf (void *a, const char *b, const
char *c, const char *d)
{
  if (a == 0 || *c != 'x' || *d != 'x' || b == 0)
    abort ();
  asm volatile ("");
}

void __attribute__ ((__noinline__))
cris_target_asm_function_prologue (void *file, long got_really_used)
{
  if (got_really_used)
    {
      asm_fprintf (file, "%s %s\n",
       reg_names[(flag_pic ? 0 : (~(unsigned int) 0))],
       reg_names[(flag_pic ? 0 : (~(unsigned int) 0))]);
    }
  asm_fprintf (file, "", "x", "x");
}

int main (void)
{
  flag_pic = 2;
  cris_target_asm_function_prologue ("", 1);
  exit (0);
}

There's a spurious warning emitted with -Wall:
x.c: In function 'cris_target_asm_function_prologue':
x.c:17: warning: array subscript is above array bounds
and a tell-tale SEGV-causing instruction:
 movabsq reg_names+34359738360, %rax
(corresponding to a read of reg_names[~(unsigned int) 0] into %rax)
which is wrongly moved *before* the flag_pic test.


-- 
           Summary: SEGV, conditional execution proactively executed the
                    false arm.
           Product: gcc
           Version: 4.3.3
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: hp at gcc dot gnu dot org
  GCC host triplet: x86_64-unknown-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37889


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

end of thread, other threads:[~2009-07-14  9:34 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-22  2:26 [Bug middle-end/37889] New: SEGV, conditional execution proactively executed the false arm hp at gcc dot gnu dot org
2008-10-22  2:27 ` [Bug middle-end/37889] " hp at gcc dot gnu dot org
2008-10-22  2:42 ` hp at gcc dot gnu dot org
2008-10-22 11:57 ` hp at gcc dot gnu dot org
2008-10-22 14:28 ` [Bug rtl-optimization/37889] [4.3 Regression] " rguenth at gcc dot gnu dot org
2008-10-22 14:30 ` [Bug rtl-optimization/37889] [4.3/4.4 " rguenth at gcc dot gnu dot org
2008-10-22 16:29 ` jakub at gcc dot gnu dot org
2008-11-01 12:06 ` rguenth at gcc dot gnu dot org
2009-01-21  3:53 ` hp at gcc dot gnu dot org
2009-01-24 10:26 ` rguenth at gcc dot gnu dot org
2009-01-31 15:32 ` bonzini at gnu dot org
2009-01-31 22:25 ` hp at gcc dot gnu dot org
2009-01-31 23:35 ` hp at gcc dot gnu dot org
2009-02-01  5:54 ` hp at gcc dot gnu dot org
2009-02-03 15:15 ` bonzini at gnu dot org
2009-02-03 15:19 ` bonzini at gnu dot org
2009-02-03 15:49 ` bonzini at gnu dot org
2009-02-03 16:34 ` hp at gcc dot gnu dot org
2009-02-03 16:40 ` bonzini at gnu dot org
2009-02-03 17:54 ` hp at gcc dot gnu dot org
2009-02-03 17:57 ` bonzini at gnu dot org
2009-02-04 20:55 ` bonzini at gcc dot gnu dot org
2009-02-06  9:06 ` [Bug rtl-optimization/37889] [4.3 " bonzini at gnu dot org
2009-06-25 20:11 ` rguenth at gcc dot gnu dot org
2009-07-14  9:33 ` rguenth at gcc dot gnu dot org
2009-07-14  9:34 ` rguenth at gcc dot gnu dot org

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