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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 8 January 2017 at 19:20, Sergiu Ivanov <sivanov@xxxxxxxxxxx> wrote:
>
> 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.

I don't think it has anything to do with containers or heap
allocations (std::list doesn't allocate anything in its default
constructor), but any type with a non-trivial default constructor
and/or non-trivial destructor. std::list just happens to be one such
type.

> 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.

Yes, I'm fairly sure there are several existing bugs about large
initializer lists using too much memory.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux