title: Why "initializer element is not a constant" is... not working anymore?
body: <pre><code>static const int a = 42;
  static const int b = a;
  </code></pre>
  
  <p>I would expect a compilation error in such code. The initializer must be a constant expression or a string literal. A value stored in an object with the type <code>int</code> with <code>const</code> type qualifier is not a constant expression.</p>
  
  <p>I compile with <code>-Wall -Wextra -pedantic</code>, even with <code>-ansi</code>. Then:</p>
  
  <ul>
  <li>the code compiles fine on <a href="https://godbolt.org/z/mNZ59z" rel="noreferrer">gcc8.2</a> and gcc 8.1</li>
  <li>the code fails to compile on <a href="https://godbolt.org/z/ke1vnF" rel="noreferrer">gcc lower then 7.4</a> with <code>error: initializer element is not constant</code></li>
  <li>the code compiles fine on <a href="https://godbolt.org/z/fxXvQr" rel="noreferrer">all clang versions</a></li>
  </ul>
  
  <p>Surprisingly, the following:</p>
  
  <pre><code>static const char * const a = "a";
  static const char * const b = a;
  </code></pre>
  
  <ul>
  <li>works on <a href="https://godbolt.org/z/ZjSN8X" rel="noreferrer">gcc 8.2</a></li>
  <li>fails on <a href="https://godbolt.org/z/LHhRmO" rel="noreferrer">gcc below 7.4</a> with <code>error: initializer element is not constant</code></li>
  <li>works on <a href="https://godbolt.org/z/phNCOR" rel="noreferrer">clang greater then 4.0</a></li>
  <li>fails on <a href="https://godbolt.org/z/NiFB1-" rel="noreferrer">clang lower then 3.9.1</a> with <code>error: initializer element is not a compile-time constant</code></li>
  </ul>
  
  <p>For the snipped below, I think I was 100% sure that it should not compile:</p>
  
  <pre><code>static const int a[] = { 1, 2, 3 };
  static const int b = a[1];
  </code></pre>
  
  <p>, but:</p>
  
  <ul>
  <li>it works on <a href="https://godbolt.org/z/27rpkd" rel="noreferrer">gcc 8.2</a></li>
  <li>it fails on <a href="https://godbolt.org/z/-IO-sh" rel="noreferrer">gcc lower then 7.4</a> with <code>error: initializer element is not constant</code></li>
  <li>and it fails on any version of <a href="https://godbolt.org/z/N2bgo2" rel="noreferrer">clang</a></li>
  </ul>
  
  <p>I tried browsing the net for an explanation, which mostly resulted in copying the code out of old stackoverflow questions about not constant intializers and finding out if they work now. I couldn't find anything relevant in <a href="https://gcc.gnu.org/gcc-8/changes.html" rel="noreferrer">gcc 8 changes</a>.</p>
  
  <p>I am lost. Is it expected behavior and such code should compile? Why/Why not? What changed between gcc7.4 and gcc8.1? Is this a compiler bug? Is this a compiler extension?</p>