This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/47980] Inefficient code for local const char arrays
- From: "pinskia at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 3 Mar 2011 22:00:45 +0000
- Subject: [Bug middle-end/47980] Inefficient code for local const char arrays
- Auto-submitted: auto-generated
- References: <bug-47980-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47980
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|REOPENED |RESOLVED
Component|c |middle-end
Resolution| |INVALID
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> 2011-03-03 22:00:36 UTC ---
Actually the copying is correct.
Take:
void f(const char *p);
void g(int t) {
const char foo[] = "aoeuaoeuaeouaeouaoeuaoeaoxbxod";
f(foo, t);
if (!t)
g(1);
}
const char *a;
void f(const char *p, int t)
{
if (!t)
a = p;
else if (a == p)
abort ();
}
void main(void)
{
g(0);
}
This program should not abort with your "optimization", it will.