Take:
int main()
{
  char str[2][34] = {"a","b"};

  __builtin_puts(str[0]);

  return 0;
}

In 4.0.2, we used to get:
  static char C.0[2][34] = {"a", "b"};
      char str[2][34];

      str = C.0;
      __builtin_puts (&str[0][0]);


But in 4.1.1 and above, we get:
  char str[2][34];

  str = {};
  str[0] = "a";
  str[1] = "b";

Which causes us to first zero out the array and then do load/stores on the
stack.


-- 
           Summary: [4.1/4.2/4.3 Regression] Not promoting an whole array to
                    be static const
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pinskia at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31150

Reply via email to