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 c++/53220] [4.7/4.8 Regression] g++ mis-compiles compound literals


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

--- Comment #8 from Jason Merrill <jason at gcc dot gnu.org> 2012-05-07 17:44:52 UTC ---
The thing is, C++11 introduces list-initialized temporaries; I could rewrite
the testcase in C++11 as

extern "C" int printf (const char *, ...);

int main()
{
  typedef int AR[4];
  for (int *p = AR{1,2,3,0}; *p; ++p)
    {
      printf ("%d\n", *p);
    }
  return 0;
}

so it made sense to me for compound literals to have the same semantics;
otherwise you have a difference in lifetime based on whether or not the type is
wrapped in parentheses.

I definitely agree that we need to give a diagnostic about taking the address
of a temporary here.


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