public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ulyssesric at yahoo dot com dot tw" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/21834] New: Error when passing unsigned long long as function arguments
Date: Tue, 31 May 2005 01:22:00 -0000	[thread overview]
Message-ID: <20050531001655.21834.ulyssesric@yahoo.com.tw> (raw)

I have a function that takes two usigned-long-long variables and two unsigned-char variables as 
argument.  Here is the sample code:

typedef unsigned char byte_t;
typedef unsigned long long qword_t;
void foo(
    byte_t state,
    qword_t srcAddr,
    byte_t routeOptions,
    qword_t dstAddr
) {
    ...
}
void main(void) {
    ....
    foo(0x00,0x1234ll,0x01, 0x5678ll);
    ....
}

Compiled with avr-gcc 3.4.3, for Atmega 128:

avr-gcc -mmcu=atmega128 -g -Os -Wall -Wa,-adhlns=func1.o -std=gnu99 -funsigned-char 
-funsigned-bitfields -fpack-struct -fshort-enums -ffreestanding -c func1.c -o func1.o

When I tried to check the values of variable srcAddr and dstAddr within foo() using UART, they are not 
what they should be. srcAddr is something like 0xDE00000000001A6D,  and dstAddr is 
0x7800000000000056.

However, If I change the order of these arguments to :

void foo(
    qword_t srcAddr,
    qword_t dstAddr,
    byte_t state,
    byte_t routeOptions
) {
    ...
}

and the result would be correct.

-- 
           Summary: Error when passing unsigned long long as function
                    arguments
           Product: gcc
           Version: 3.4.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ulyssesric at yahoo dot com dot tw
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: X86 (Linux, Win32) and PowerPC (Darwin)
GCC target triplet: AVR, Atmega128


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


             reply	other threads:[~2005-05-31  0:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-31  1:22 ulyssesric at yahoo dot com dot tw [this message]
2005-05-31  3:35 ` [Bug target/21834] " pinskia at gcc dot gnu dot org
2005-05-31  3:38 ` ulyssesric at yahoo dot com dot tw
2005-05-31  3:41 ` ulyssesric at yahoo dot com dot tw
2005-06-19 14:02 ` pinskia 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=20050531001655.21834.ulyssesric@yahoo.com.tw \
    --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).