From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30507 invoked by alias); 19 Jan 2006 17:54:20 -0000 Received: (qmail 30462 invoked by uid 48); 19 Jan 2006 17:54:17 -0000 Date: Thu, 19 Jan 2006 17:54:00 -0000 Message-ID: <20060119175417.30461.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug rtl-optimization/25791] -O2 execution fails, -O and -g work In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "dick_guertin at yahoo dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2006-01/txt/msg01967.txt.bz2 List-Id: ------- Comment #24 from dick_guertin at yahoo dot com 2006-01-19 17:54 ------- Although you have closed this, many people would disagree with you. Laying out static data this way has always 'worked' in the past, and continues to work with -O, but not -O2. Just for completeness, here is a simplfied testcase.c that anyone can compile and execute with -O or -O2. #include typedef struct sckw { unsigned char tok[1]; char tag[3]; } NKW; /* user sckws */ static struct sckw sckw01 = { 1, '0','1', 0 }; static struct sckw sckw02 = { 2, '0','2', 0 }; static struct sckw sckw03 = { 3, '0','3', 0 }; static struct sckw sckw04 = { 4, '0','4', 0 }; static struct sckw sckw05 = { 5, '0','5', 0 }; static struct sckw sckw06 = { 6, '0','6', 0 }; static struct sckw sckw07 = { 7, '0','7', 0 }; static struct sckw sckw08 = { 8, '0','8', 0 }; static struct sckw sckw09 = { 9, '0','9', 0 }; static struct sckw sckw10 = { 10, '1','0', 0 }; static struct sckw sckw11 = { 11, '1','1', 0 }; static struct sckw sckw12 = { 12, '1','2', 0 }; static struct sckw sckw13 = { 13, '1','3', 0 }; static struct sckw sckw14 = { 14, '1','4', 0 }; static struct sckw sckw15 = { 15, '1','5', 0 }; static struct sckw sckw16 = { 16, '1','6', 0 }; static struct sckw sckw17 = { 17, '1','7', 0 }; static struct sckw sckw18 = { 18, '1','8', 0 }; static struct sckw sckw19 = { 19, '1','9', 0 }; static struct sckw sckw20 = { 0, '2','0', 0 }; void scanner (void) { int token; NKW *kwp, *kwp2; kwp = (NKW*) &(sckw01); kwp2 = (NKW*) &(sckw20); token = 1; while (kwp) { if ((int)kwp->tok[0] == token) { ++ token; kwp += 1; } else { if ((kwp == kwp2) && (token == 20)) printf("Finished correctly\n"); else printf("Finished at %d when tok=%d\n", token, (int)kwp->tok[0]); kwp = 0; } } return; } int main () { scanner(); return(0); } -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25791