bugAVR C Runtime Library - Bugs: bug #34278, Seemingly overzealous...

 
 

bug #34278: Seemingly overzealous "__builtin_avr_delay_cycles expects an integer constant"

Submitted by:  Yann Dirson <ydirson>
Submitted on:  Mon 12 Sep 2011 09:55:32 PM UTC  
 
Category: HeaderSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Header files
Status: InvalidPercent Complete: 0%
Assigned to: Joerg Wunsch <joerg_wunsch>Open/Closed: Closed
Release: 1.7.1Fixed Release: None

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Wed 14 Sep 2011 07:52:14 AM UTC, comment #2:

Thanks for the archive, now I finally see the problem. Sorry
for being blind in the first place.

The compiler is correct. The code is:

Thus, _delay_ms() is called with "ms" which is a function
parameter. This is not supported (and has never been, but
with the current implementation, you finally get an error
while the code simply didn't do what it was expected to
do before).

A correct (with respect to what the comment above the
function says) implementation would look like:

In addition (and unlike the original comment), optimization
must be turned on for any of the _delay_us/ms functions
to work correctly.

Joerg Wunsch <joerg_wunsch>
Project AdministratorIn charge of this item.
Tue 13 Sep 2011 08:04:36 AM UTC, comment #1:

The strange thing is I cannot reproduce that at all.

I've got another report owhere this happened, but there,
-ffreestanding was in effect, preventing the compiler from
resolving the calls to fabs() and ceil() at compile-time.
We have to find a solution to that problem.

In your case, there's no -ffreestanding though, and if I
compile a smimple test program using your compiler options,
all works fine.

Can you please run the compiler with the additional option
-da, then pack all the StdDefs.* files into an archive, and
attach that archive to this bug tracker?

Joerg Wunsch <joerg_wunsch>
Project AdministratorIn charge of this item.
Mon 12 Sep 2011 09:55:32 PM UTC, original submission:

The problem occurs while compiling examples/atmel_key/ in simulavr (master from git), on a Debian testing amd64 host:

make[2]: Entering directory `/work/yann/elec/avr/simulavr/examples/atmel_key'
avr-gcc -mmcu=atmega128 -I. -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -c -o StdDefs.o StdDefs.c
StdDefs.c: In function ‘putstr’:
StdDefs.c:122:4: warning: pointer targets in passing argument 1 of ‘strlen’ differ in signedness
/usr/lib/gcc/avr/4.5.3/../../../avr/include/string.h:133:15: note: expected ‘const char ’ but argument is of type ‘CHARU
In file included from StdDefs.c:8:0:
/usr/lib/gcc/avr/4.5.3/../../../avr/include/util/delay.h: In function ‘msleep’:
/usr/lib/gcc/avr/4.5.3/../../../avr/include/util/delay.h:153:28: error: __builtin_avr_delay_cycles expects an integer constant.
make[2]: *** [StdDefs.o] Error 1

The _delay_ms() cpp expansion looks correct, though - seems strange at first sight:

# 132 "/usr/lib/gcc/avr/4.5.3/../../../avr/include/util/delay.h" 3
void
_delay_ms(double __ms)
{
uint16_t __ticks;
double __tmp ;

uint32_t __ticks_dc;
extern void __builtin_avr_delay_cycles(unsigned long);
__tmp = ((4000000UL) / 1e3) * __ms;
# 150 "/usr/lib/gcc/avr/4.5.3/../../../avr/include/util/delay.h" 3
__ticks_dc = (uint32_t)(ceil(fabs(__tmp)));

Yann Dirson <ydirson>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #23972:  stddefs.tgz added by ydirson (54KiB - application/x-compressed-tar - The -da archive)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by joerg_wunsch (Posted a comment)
  • -unavailable- added by ydirson (Submitted the item)
  •  

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 5 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 14 Sep 2011 07:52:14 AM UTCjoerg_wunschStatusNeed Info=>Invalid
      Assigned toNone=>joerg_wunsch
      Open/ClosedOpen=>Closed
    Tue 13 Sep 2011 06:52:23 PM UTCydirsonAttached File-=>Added stddefs.tgz, #23972
    Tue 13 Sep 2011 08:04:36 AM UTCjoerg_wunschStatusNone=>Need Info

    Back to the top


    Powered by Savane 3.1-cleanup1