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

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

 



On 08/01/2017 20:20, Sergiu Ivanov wrote:

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

I use the Compiler Explorer to quickly test new versions.

https://godbolt.org/

I can reproduce your issue on 5.4

Killed - processing time exceeded
g++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
Compiler exited with result code null

Same with 6.3

Same with 7 snapshot.

I tried running on my system, which started thrashing, so I'm assuming
gcc is trying to allocate too much memory, and gets zapped by the OOM
ninja?

Regards.




[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