[Top][All Lists]

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

Re: [avr-gcc-list] Stack-allocated array bug

From: Georg-Johann Lay
Subject: Re: [avr-gcc-list] Stack-allocated array bug
Date: Wed, 13 Apr 2011 14:47:40 +0200
User-agent: Thunderbird (X11/20100302)

Cory Cross schrieb:
> Hi all,
> I've been running into several problems with avr-gcc from the Debian
> unstable repo which is at version 4.3.5. I am compiling for ATMega168.
> This problem was also present going back to compilers from 2007.
> All the problems traced down to a stack-allocated array whose pointer
> ends up being set at or near 0x100 (whether that's over end of RAM or
> not, I'm not sure), which when written starts clobbering the .data
> section. But it only seems to happen in complex cases.
> Contrary to the names of the files, I'm not sure whether the following
> demonstrates what I'm saying.
> In clobber.lss lines 50&51, r28 is set to 0xFF and r29 to 0x04.
> In no-clobber.lss on the same lines, the same occurs.
> In clobber.lss, r12&r13 become the address for adc_readings[8].
> In no-clobber.lss, r22&r23 become the address for adc_readings[8].
> But the setup is different in the no-clobber case. In clobber.lss lines
> 107-110 differ from no-clobber.lss lines 102-104 even though I don't
> think they have to. This is the source of my problem I believe.
> For now, I just can't have stack-allocated arrays :(.

Where do you expect should these arrays be placed?
You make main naked, so avr-gcc won't set up a frame pointer for you,
however, it will use Y as frame pointer, anyway.

That's no bug in the compiler, you intentionally shred your code.


> Thanks for any help,
> Cory

reply via email to

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