This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/49079] [4.6/4.7 Regression] Bogus constant folding
- From: "rguenth at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 20 May 2011 13:43:07 +0000
- Subject: [Bug tree-optimization/49079] [4.6/4.7 Regression] Bogus constant folding
- Auto-submitted: auto-generated
- References: <bug-49079-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49079
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2011.05.20 13:28:05
Ever Confirmed|0 |1
--- Comment #4 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-05-20 13:28:05 UTC ---
Because the array length is of size 1 and get_ref_base_and_extent returns an
exact match in that case. We have to account for trailing flexible arrays.
Testcase:
extern void abort (void);
struct Ustr
{
unsigned char data[1];
};
static unsigned int
ustr_xi__embed_val_get(const unsigned char *data)
{
return (unsigned int)data[0];
}
int __attribute__((noinline)) zero(void) { return 0; }
static unsigned int
ustr_len(const struct Ustr *s1)
{
return ustr_xi__embed_val_get(s1->data + 1 + zero());
}
int
main()
{
if (ustr_len (((struct Ustr *) "\x01" "\x0002" "s2")) != 2)
abort ();
return 0;
}