[Bug c++/92745] [8/9 Regression] Initializing array with vec4 results in compile error

2020-02-25 Thread cvs-commit at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92745

--- Comment #10 from CVS Commits  ---
The releases/gcc-8 branch has been updated by Jason Merrill
:

https://gcc.gnu.org/g:a955c8f0a0aacd9271876ddc5ca8f0ccaca18ac7

commit r8-10065-ga955c8f0a0aacd9271876ddc5ca8f0ccaca18ac7
Author: Marek Polacek 
Date:   Fri Dec 20 23:30:04 2019 +

PR c++/92745 - bogus error when initializing array of vectors.

In r268428 I changed reshape_init_r in such a way that when it sees
a nested { } in a CONSTRUCTOR with missing braces, it just returns
the initializer:
+ else if (COMPOUND_LITERAL_P (stripped_init)
...
+ ++d->cur;
+ gcc_assert (!BRACE_ENCLOSED_INITIALIZER_P (stripped_init));
+ return init;

But as this test shows, that's incorrect: if TYPE is an array, we need
to proceed to reshape_init_array_1 which will iterate over the array
initializers:
 6006   /* Loop until there are no more initializers.  */
 6007   for (index = 0;
 6008d->cur != d->end && (!sized_array_p || index <=
max_index_cst);
 6009++index)
 6010 {
and update d.cur accordingly.  In other words, when reshape_init gets

{{col[0][0], col[1][0], col[2][0], col[3][0]},
 {col[0][1], col[1][1], col[2][1], col[3][1]},
 {col[0][2], col[1][2], col[2][2], col[3][2]},
 {col[0][3], col[1][3], col[2][3], col[3][3]}}

we recurse on the first element:
  {col[0][0], col[1][0], col[2][0], col[3][0]}
and we can't just move d.cur to point to
  {col[0][1], col[1][1], col[2][1], col[3][1]}
and return; we need to iterate, so that d.cur ends up being properly
updated, and after all initializers have been seen, points to d.end.
Currently we skip the loop, wherefore we hit this:

 6502   /* Make sure all the element of the constructor were used.
Otherwise,
 6503  issue an error about exceeding initializers.  */
 6504   if (d.cur != d.end)
 6505 {
 6506   if (complain & tf_error)
 6507 error ("too many initializers for %qT", type);
 6508   return error_mark_node;
 6509 }

gcc/cp/ChangeLog
2020-02-25  Marek Polacek  

PR c++/92745 - bogus error when initializing array of vectors.
* decl.c (reshape_init_r): For a nested compound literal, do
call reshape_init_{class,array,vector}.

gcc/testsuite/ChangeLog
2020-02-25  Marek Polacek  
Jakub Jelinek  

PR c++/92745
* g++.dg/cpp0x/initlist118.C: New test.
* g++.dg/cpp0x/initlist118.C: Add -Wno-psabi -w to dg-options.

[Bug c++/92745] [8/9 Regression] Initializing array with vec4 results in compile error

2019-12-29 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92745

--- Comment #9 from Jakub Jelinek  ---
Author: jakub
Date: Sun Dec 29 23:47:55 2019
New Revision: 279758

URL: https://gcc.gnu.org/viewcvs?rev=279758&root=gcc&view=rev
Log:
PR c++/92745
* g++.dg/cpp0x/initlist118.C: Add -Wno-psabi -w to dg-options.

Modified:
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/g++.dg/cpp0x/initlist118.C

[Bug c++/92745] [8/9 Regression] Initializing array with vec4 results in compile error

2019-12-20 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92745

Marek Polacek  changed:

   What|Removed |Added

Summary|[8/9/10 Regression] |[8/9 Regression]
   |Initializing array with |Initializing array with
   |vec4 results in compile |vec4 results in compile
   |error   |error

--- Comment #8 from Marek Polacek  ---
Fixed on trunk so far.