hI;
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));
#endif

ACAV


From:   <lbuch...@hsr.ch>
To:     <avr-gcc-list@nongnu.org>, 
Date:   01.12.2012 19:15
Subject:        [avr-gcc-list] maybe a bug in gcc-avr?
Sent by:        
avr-gcc-list-bounces+andreasclaudius.vogel=camco...@nongnu.org



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));
#endif
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:
http://www10.pic-upload.de/28.11.12/1afla5oyatlv.jpg

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
AVR-GCC-list@nongnu.org
https://lists.nongnu.org/mailman/listinfo/avr-gcc-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

_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
https://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Reply via email to