Bug 1318619

Summary: cc1plus crash compiling huge extended initializer list of std::vector<std::string>
Product: [Fedora] Fedora Reporter: Dmitry Antipov <dmantipov>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED WONTFIX QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 22CC: davejohansen, jakub, jwakely, law, mpolacek
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-03-17 14:57:15 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Attachments:
Description Flags
Preprocessed translation unit none

Description Dmitry Antipov 2016-03-17 11:21:38 UTC
Created attachment 1137360 [details]
Preprocessed translation unit

Description of problem:

Program cc1plus crashes with ICE on valid input.

Version-Release number of selected component (if applicable):

gcc version 5.3.1 20151207 (Red Hat 5.3.1-2) (GCC)

How reproducible:

100% reproducible.

Steps to Reproduce:

/usr/libexec/gcc/x86_64-redhat-linux/5.3.1/cc1plus -quiet -std=c++11 -fpreprocessed test.ii

Actual results:

Segmentation fault (core dumped)

Expected results:

Default executable (a.out) should be generated.

Comment 1 Jakub Jelinek 2016-03-17 13:52:54 UTC
This runs out of stuck during garbage collection in the compiler, because the testcase is just insane.  Why would you do something so silly?
int main () {
std::vector<std::string> v {
// 200000 string literals here
};
}
Even if you manage to compile this, it is insanely costly at runtime.  If you really need them in the form of std::vector<std::string> with 200000 elements, better add the literals into static const char *vv[] = {
// 200000 string literals here
};
allocate a vector with length 200000 and push them in a loop.

Comment 2 Jakub Jelinek 2016-03-17 14:57:15 UTC
Filed PR70277 to track possible enhancement here, but it will not happen before GCC 7 next year.  In the mean time, just use C++ wisely.