1

So I've found this code works:

int foo[] = {0, foo[0] + 1, foo[1] + 2, foo[2] + 4 };

Is this officially legal? I thought that I was making an initializer_list here, but if I can access previously initialized elements this must be doing aggregate initialization.

I tried to find an official statement on the legality of this, but I couldn't seem to.

Rakete1111
  • 47,013
  • 16
  • 123
  • 162
Jonathan Mee
  • 37,899
  • 23
  • 129
  • 288
  • 5
    [You have already asked this question](https://stackoverflow.com/questions/33828350/can-i-reference-previous-members-of-an-initializer-list) – NathanOliver Jul 10 '18 at 13:05
  • 1
    It seems that duplicate is from 2015, and the answer to this question disagrees with the linked duplicate. This makes me wonder what is the proper way to request an update on an old question when changes to the language make that question's answers incorrect? – François Andrieux Jul 10 '18 at 13:09

0 Answers0