This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/47980] Inefficient code for local const char arrays


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]