[PATCH] don't treat as zero empty string initializers of pointer array elements (PR 89980)

Marek Polacek polacek@redhat.com
Fri Apr 5 18:21:00 GMT 2019


On Fri, Apr 05, 2019 at 10:45:59AM -0600, Martin Sebor wrote:
> The change committed yesterday to handle the C++ 2a string literals
> as non-type template arguments treats empty string initializers for
> trailing pointer array elements as zero.  That's of course wrong
> because addresses of literals are non-zero.

That patch (r270155) also broke constexpr-63241.C:

constexpr-63241.C: In function ‘int main()’:
constexpr-63241.C:12:16: error: could not convert ‘<brace-enclosed initializer list>()’ from ‘<brace-enclosed initializer list>’ to ‘A’
   12 |      {{0}, {0}}};
      |                ^
      |                |
      |                <brace-enclosed initializer list>

We have an initializer for a multidimensional array of A, and somehow the
truncating of the elements breaks it.

Marek



More information about the Gcc-patches mailing list