This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
Re: c/8083: GCC 3.2 Optimization bug
- From: Bruce Korb <bkorb at pacbell dot net>
- To: nobody at gcc dot gnu dot org
- Cc: gcc-prs at gcc dot gnu dot org,
- Date: 28 Sep 2002 23:56:01 -0000
- Subject: Re: c/8083: GCC 3.2 Optimization bug
- Reply-to: Bruce Korb <bkorb at pacbell dot net>
The following reply was made to PR c/8083; it has been noted by GNATS.
From: Bruce Korb <bkorb@pacbell.net>
To: gcc-gnats@gcc.gnu.org, bkorb@gnu.org
Cc:
Subject: Re: c/8083: GCC 3.2 Optimization bug
Date: Sat, 28 Sep 2002 16:55:18 -0700
The following diff of the routine works, so clearly it is an
aliasing optimization issue. It looks like the optimizer
presumesthat "list" is not modified by the line:
*ppT = pDef;
*However*, since "ppT" is explicitly set to point to "list",
it is clearly an alias and not one to be optimized away.
diff -u -r3.7 defReduce.c
--- defReduce.c 15 Jun 2002 18:24:59 -0000 3.7
+++ defReduce.c 28 Sep 2002 23:32:03 -0000
@@ -121,9 +121,10 @@
YYSTYPE def,
YYSTYPE list )
{
+ tDefEntry* ret = (tDefEntry*)list;
tDefEntry* pDef = (tDefEntry*)def;
- tDefEntry* pScn = (tDefEntry*)list;
- tDefEntry** ppT = (tDefEntry**)&list;
+ tDefEntry* pScn = ret;
+ tDefEntry** ppT = &ret;
for (;;) {
if (strcmp( pDef->pzDefName, pScn->pzDefName ) == 0) {
@@ -166,9 +169,8 @@
* THEN put the new entry at the start of the list
*/
if (pScn->pNext == NULL) {
-
pDef->pNext = (tDefEntry*)list;
- list = def;
+ ret = (tDefEntry*)def;
break;
}
@@ -181,7 +183,7 @@
pScn = pScn->pNext;
}
- return list;
+ return (YYSTYPE)ret;
}