From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19703 invoked by alias); 28 Jul 2010 06:07:25 -0000 Received: (qmail 19618 invoked by uid 48); 28 Jul 2010 06:07:10 -0000 Date: Wed, 28 Jul 2010 06:07:00 -0000 Subject: [Bug c/45099] New: Warning could be issued for use of register variables that will fail. X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "jrseattle2002 at hotmail dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2010-07/txt/msg03026.txt.bz2 WinAVR needs register r10 (among others) for certain mathematical operations of the "long long" data type, e.g. when calling "__muldi3". The user may declare r10 to be assigned to a register variable. When this combination occurs, code will not execute correctly. This is specifically an issue when the register variable is NOT used in ISR functions and the user expects r10 to be "call saved". WinAVR normally saves these "call saved" registers in the function that uses them, but DOES NO DO THAT IF THE REGISTER IS USED AS A REGISTER VARIABLE, even though it needs to use that register. Such situations can be recognized and a warning issued. Even better, the register could be saved in the first place using the rule "call saved" registers need to be saved by the called function if used, even if the register is used as a register variable. Sample code: register unsigned char GYOffset asm("r10"); typedef unsigned char byte; typedef unsigned int uint; void ComputeLargeNum(uint nDays, char *pStr) { unsigned long long LargeNum = 13248524997010ULL + nDays * 4173424303; uint n = 0; while (LargeNum > 1000000000ULL) { ++n; LargeNum -= 1000000000ULL; } } void print(char *pStr) { } int main(void) { char buf[20]; GYOffset = 1; ComputeLargeNum(10, buf); if (GYOffset != 1) { print("r10 corrupted\n"); } } -- Summary: Warning could be issued for use of register variables that will fail. Product: gcc Version: 4.3.3 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jrseattle2002 at hotmail dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45099