This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/19828] [4.0 Regression] LIM is pulling out a pure function even though there is something which can modify global memory
- From: "jakub at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 18 Feb 2005 15:55:36 -0000
- Subject: [Bug tree-optimization/19828] [4.0 Regression] LIM is pulling out a pure function even though there is something which can modify global memory
- References: <20050208190328.19828.pinskia@gcc.gnu.org>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From jakub at gcc dot gnu dot org 2005-02-18 15:55 -------
Just got hit by this too on subversion.
Distilled testcase is:
typedef __SIZE_TYPE__ size_t;
extern size_t strlen (const char *s);
extern int strncmp (const char *s1, const char *s2, size_t n);
extern void abort (void);
const char *a[16] = { "a", "bc", "de", "fgh" };
int
foo (char *x, const char *y, size_t n)
{
size_t i, j = 0;
for (i = 0; i < n; i++)
{
if (strncmp (x + j, a[i], strlen (a[i])) != 0)
return 2;
j += strlen (a[i]);
if (y)
j += strlen (y);
}
return 0;
}
int
main (void)
{
if (foo ("abcde", (const char *) 0, 3) != 0)
abort ();
return 0;
}
With Zdenek's definition of pure the only pure functions in builtins.def
would be is*/to*, none of the string/memory functions could be. But the
documentation explicitely mentions strlen and memcmp as pure functions.
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at redhat dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19828