g++ trouble with empty initialiser list for big std::array

Sergiu Ivanov sivanov@colimite.fr
Sun Jan 8 19:21:00 GMT 2017


Dear GCC hackers,

Consider the following code (also attached with additional examples as
bug.c):


  #include <array>
  #include <list>

  #define SIZE 1000000
  int main() {
    std::array< std::list< char >, SIZE > x{};
    return 0;
  }


When I run the command `time g++ -std=c++11 bug.c`, I get the following
output:

  g++: internal compiler error: Segmentation fault (program cc1plus)
  Please submit a full bug report,
  with preprocessed source if appropriate.
  See <http://gcc.gnu.org/bugs.html> for instructions.
  g++ -std=c++11 bug.c  47.52s user 2.95s system 99% cpu 50.586 total


As shown in the attached source file bug.c, this problem only seems to
occur when the element type is an STL container potentially allocating
on the heap, i.e. the following 

 std::array< std::array< char, 26 >, SIZE > x{};

compiles fine.  Finally, the same code (using std::list) compiles fine
if I don't give any initialiser list at all.

My version of g++ is 5.4.0.

Is it a known g++ bug?  I've vaguely seen people report similar issues
(I lost the link :-( ), but I couldn't quickly find anything on the bug
tracker.


Please keep me in CC as I am not subscribed to the list.  Thank you!

-- 
Sergiu
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bug.c
Type: application/octet-stream
Size: 440 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-help/attachments/20170108/329506aa/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 487 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-help/attachments/20170108/329506aa/attachment.sig>


More information about the Gcc-help mailing list