Summary: | g++ string array in struct crash | ||
---|---|---|---|
Product: | gcc | Reporter: | Graeme Paterson <gpkiwi> |
Component: | c++ | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | RESOLVED DUPLICATE | ||
Severity: | normal | CC: | jason, webrown.cpp |
Priority: | P3 | Keywords: | compile-time-hog, missed-optimization |
Version: | 4.8.1 | ||
Target Milestone: | --- | ||
See Also: | https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92385 | ||
Host: | Target: | ||
Build: | Known to work: | ||
Known to fail: | Last reconfirmed: | 2015-03-26 00:00:00 | |
Bug Depends on: | |||
Bug Blocks: | 65591 | ||
Attachments: | file produced by >gcc -v -save-temps -Wall -Wextra c.cc |
Description
Graeme Paterson
2015-03-21 09:51:54 UTC
You're creating a huge object on the stack, which is a bad idea, and the problem is probably that GCC is running out of memory. Also, I noticed that in some cases GCC is able to generate a loop for initialization: #include <string> int main() { std::string m[1000] {"x", "y"}; std::string n[1000] = {"x", "y"}; } That is done in cp/init.c:build_vec_init. But for the original testcase, the loop is not created. Is it a bug? (In reply to Mikhail Maltsev from comment #2) > Also, I noticed that in some cases GCC is able to generate a loop for > initialization: > > #include <string> > > int main() { > std::string m[1000] {"x", "y"}; > std::string n[1000] = {"x", "y"}; > } > > That is done in cp/init.c:build_vec_init. But for the original testcase, the > loop is not created. Is it a bug? It's a poor optimization choice; we ought to build a loop for member array initialization as well as array variables. |