public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/57321] New: static function call miscompiled at -Os and above
@ 2013-05-17 22:35 dhazeghi at yahoo dot com
  2013-05-18 11:48 ` [Bug rtl-optimization/57321] " mikpe at it dot uu.se
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: dhazeghi at yahoo dot com @ 2013-05-17 22:35 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 57321
           Summary: static function call miscompiled at -Os and above
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dhazeghi at yahoo dot com

The testcase below is miscompiled by gcc 4.8 on x86_64-linux, resulting in a
segfault when built with -Os or higher optimization levels.  This does not
occur with gcc 4.7 or current trunk.  The segfault appears on line 8, where p
is dereferenced and compared.

$ gcc-4.8 -v
gcc version 4.8.0 (GCC) 
$ gcc-4.8 -O1 small.c
$ ./a.out 
$ gcc-4.7 -Os small.c
$ ./a.out 
$ gcc-4.8 -Os small.c
$ ./a.out 
Segmentation fault (core dumped)

------------------------

int a = 1;
int *b;
int **c;

static int
bar(int *p)
{
    if (*p == a)
    {
        int *i[7][1][9] = {{{ 0 }}};
        int **j[1][1][1];
        j[0][0][0] = &i[0][0][0] ;
        *b = &p != c;
    }
    return 0;
}


void
foo(int p, int q)
{
    int i = 0;
    if (bar (&i))
        ;
}

int
main()
{
    foo (0, 0);
    return 0;
}


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

end of thread, other threads:[~2013-05-21  8:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-17 22:35 [Bug rtl-optimization/57321] New: static function call miscompiled at -Os and above dhazeghi at yahoo dot com
2013-05-18 11:48 ` [Bug rtl-optimization/57321] " mikpe at it dot uu.se
2013-05-21  7:26 ` [Bug rtl-optimization/57321] [4.8/4.9 Regression] " jakub at gcc dot gnu.org
2013-05-21  8:00 ` [Bug tree-optimization/57321] " jakub at gcc dot gnu.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).