This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Thus quoth  Jonathan Wakely  at 13:49 on Mon, Jan 09 2017:
> On 8 January 2017 at 19:20, Sergiu Ivanov <sivanov@colimite.fr> wrote:
>
>> 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.

Ah indeed, you're probably right, std::array does not seem to have
explicitly defined constructors [0].

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

That's what I thought as well.  I won't file an extra bug then.

Thanks for your feedback!

-- 
Sergiu

[0] https://gcc.gnu.org/onlinedocs/gcc-4.6.3/libstdc++/api/a00752_source.html

Attachment: signature.asc
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]