public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dhazeghi at yahoo dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/57321] New: static function call miscompiled at -Os and above
Date: Fri, 17 May 2013 22:35:00 -0000	[thread overview]
Message-ID: <bug-57321-4@http.gcc.gnu.org/bugzilla/> (raw)

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;
}


             reply	other threads:[~2013-05-17 22:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-17 22:35 dhazeghi at yahoo dot com [this message]
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

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=bug-57321-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).