[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] maybe a bug in gcc-avr?

From: AndreasClaudius . Vogel
Subject: Re: [avr-gcc-list] maybe a bug in gcc-avr?
Date: Mon, 3 Dec 2012 09:54:41 +0100

perhaps try to remove comments after a #define or #if define checks, in general avoid comments after a # statement.

#if 1
//depending on 'if that calculation is done', the result of bufs[0] will be 0x01 or 0x02...
                total = (((uint16_t)bufr[0]) << 8) + ((uint16_t) (bufr[1] & 0xFF));


From:        <address@hidden>
To:        <address@hidden>,
Date:        01.12.2012 19:15
Subject:        [avr-gcc-list] maybe a bug in gcc-avr?
Sent by:        address@hidden

Hello together,

I've been thinking about something for the last days. Atm I guess the
bug of my problem is in the avr-gcc.

Here my code:

uint16_t total=0, temp=0;
uint8_t bufs[64];
uint8_t bufr[64];
if (usb_rawhid_recv(bufr, 50) == 64) {
#if 1 //depending on 'if that calculation is done', the result of bufs[0] will be 0x01 or 0x02...
                total = (((uint16_t)bufr[0]) << 8) + ((uint16_t) (bufr[1] & 0xFF));
temp = (((uint16_t)bufr[0]) << 8); //temp is 0x0200
bufs[0] = temp >> 8;
bufs[1] = (((uint16_t)bufr[0]) << 8) >> 8;

Well, if bufr[0] is 0x02, then bufs[1] is also 0x02. That works fine.
But bufs[0] is calculated wrong IN CASE that i also calculate the variable "total" inside the "#if 1".
(bufs[0] is then 0x01 instead of 0x02)

The two assemblies are vimdiff'ed and shown in this image:

On the left side the working case (where total isn't calculated due to the "#if 0")
On the right side is my problem shown. I calculate the variable "total" but gcc
seems to ignore my typecasts.

What do you think?
I hope the mailing list is the right place, where I should post my
problem :)

Have a nice evening :)

AVR-GCC-list mailing list

Tel.: +49 2762 408-0
Fax.: +49 2762 408-10

Internet: http://www.camcoaudio.com

CAMCO Produktions- und Vertriebs-GmbH für Beschallungs- und Beleuchtungsanlagen - Fischpicke 5 - 57482 Wenden - Amtsgericht Siegen HRB 7075 - Geschäftsführer: Joachim Stöcker, Reiner Sassmann, Carsten Wegner

reply via email to

[Prev in Thread] Current Thread [Next in Thread]