public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "siarhei dot siamashka at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/43698]  New: Invalid code when building gentoo pax-utils-0.1.19 with -Os optimizations
Date: Fri, 09 Apr 2010 00:05:00 -0000	[thread overview]
Message-ID: <bug-43698-14457@http.gcc.gnu.org/bugzilla/> (raw)

Tested with gcc-4.5.0-RC-20100406.tar.bz2

Reduced testcase:

/*********************************************************/
#include <stdio.h>
#include <stdint.h>

char do_reverse_endian = 0;

#  define bswap_32(x) \
                        ((((x) & 0xff000000) >> 24) | \
                         (((x) & 0x00ff0000) >>  8) | \
                         (((x) & 0x0000ff00) <<  8) | \
                         (((x) & 0x000000ff) << 24))

#define EGET(X) \
        (__extension__ ({ \
                uint64_t __res; \
                if (!do_reverse_endian) {    __res = (X); \
                } else if (sizeof(X) == 4) { __res = bswap_32((X)); \
                } \
                __res; \
        }))

void __attribute__((noinline)) X(char **phdr, char **data, int *phoff)
{
    *phdr = *data + EGET(*phoff);
}

int main()
{
    char *phdr;
    char *data = (char *)0x40164000;
    int phoff = 0x34;
    X(&phdr, &data, &phoff);
    printf("got %p (expecting 0x40164034)\n", phdr);
    return 0;
}
/*********************************************************/

# gcc -Os -o test test.c
# ./test
got 0x74164000 (expecting 0x40164034)


-- 
           Summary: Invalid code when building gentoo pax-utils-0.1.19 with
                    -Os optimizations
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: siarhei dot siamashka at gmail dot com
 GCC build triplet: armv7l-unknown-linux-gnueabi
  GCC host triplet: armv7l-unknown-linux-gnueabi
GCC target triplet: armv7l-unknown-linux-gnueabi


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


             reply	other threads:[~2010-04-09  0:05 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-09  0:05 siarhei dot siamashka at gmail dot com [this message]
2010-04-09  5:49 ` [Bug target/43698] " mikpe at it dot uu dot se
2010-04-09  6:57 ` mikpe at it dot uu dot se
2010-04-09  7:02 ` ramana at gcc dot gnu dot org
2010-04-09  7:38 ` ramana at gcc dot gnu dot org
2010-04-09  7:49 ` ramana at gcc dot gnu dot org
2010-04-09  8:05 ` siarhei dot siamashka at gmail dot com
2010-04-09  8:42 ` [Bug target/43698] [4.5/4.6 Regression] " rguenth at gcc dot gnu dot org
2010-04-12  8:38 ` ramana at gcc dot gnu dot org
2010-04-12  9:34 ` siarhei dot siamashka at gmail dot com
2010-04-12  9:51   ` Ramana Radhakrishnan
2010-04-12  9:51 ` ramana dot radhakrishnan at arm dot com
2010-05-17 18:48 ` siarhei dot siamashka at gmail dot com
2010-05-19 12:25 ` rguenth at gcc dot gnu dot org
2010-07-03 16:06 ` armin76 at gentoo dot org
2010-07-19 13:54 ` [Bug target/43698] [4.5/4.6 Regression] Wrong use of ARMv6 REV instruction for endian bytewapping with -Os or -O2 optimizations siarhei dot siamashka at gmail dot com
2010-07-22  8:31 ` ramana at gcc dot gnu dot org
2010-07-22 20:54 ` siarhei dot siamashka at gmail dot com
2010-07-23 12:22 ` ramana at gcc dot gnu dot org
2010-07-23 12:28 ` rguenther at suse dot de
2010-07-30 22:36 ` ramana at gcc dot gnu dot org
2010-07-30 22:39 ` ramana at gcc dot gnu dot 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-43698-14457@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).