public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "patrick.kox at commandoregel dot be" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/100134] New: ICE when using a vector in a mdoule Date: Sun, 18 Apr 2021 09:48:16 +0000 [thread overview] Message-ID: <bug-100134-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100134 Bug ID: 100134 Summary: ICE when using a vector in a mdoule Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: patrick.kox at commandoregel dot be Target Milestone: --- Using the following code from the book (Professional C++ 5th Edition) by Marc Grergoire causes an ICE when trying to compile the "Database" module. I have 2 files: Database.cpp (the Interface, called Database.cppm in the book): === export module database; import<string>; import<vector>; import employee; namespace Records { // const int FirstEmployeeNumber{1'000}; int FirstEmployeeNumber{1'000}; export class Database{ public: Employee& addEmployee(const std::string& firstName, const std::string& lastName); Employee& getEmployee(int employeeNumber); Employee& getEmployee(const std::string& firstName, const std::string& lastName); void displayAll()const; void displayCurrent()const; void displayFormer()const; private: std::vector<Employee> m_employees; int m_nextEmployeeNumber{FirstEmployeeNumber}; }; } === And the file Database-i.cpp (called Database.cpp in the book) === module database; import<stdexcept>; using namespace std; namespace Records { Employee& Database::addEmployee(const string& firstName, const string& lastName) { Employee theEmployee{firstName, lastName}; theEmployee.setEmployeeNumber(m_nextEmployeeNumber++); theEmployee.hire(); m_employees.push_back(theEmployee); return m_employees.back(); } Employee& Database::getEmployee(int employeeNumber) { for (auto& employee : m_employees) { if (employee.getEmployeeNumber()==employeeNumber) { return employee; } } throw logic_error{"No employee found"}; } void Database::displayAll() const { for (const auto& employee : m_employees) { employee.display(); } } void Database::displayCurrent() const { for (const auto& employee : m_employees) { if (employee.isHired()) { employee.display(); } } } void Database::displayFormer() const { for (const auto& employee : m_employees) { if (!employee.isHired( )) { employee.display(); } } } } === If I try to compile this module I get the following error message: Database.cpp:4:8: internal compiler error: in add_binding_entity, at cp/module.cc:12704 4 | export module database; | ^~~~~~ 0x69ce1f depset::hash::add_binding_entity(tree_node*, WMB_Flags, void*) ../../gcc/cp/module.cc:12704 0xa3ed8c walk_module_binding(tree_node*, bitmap_head*, bool (*)(tree_node*, WMB_Flags, void*), void*) ../../gcc/cp/name-lookup.c:3964 0xa10b58 depset::hash::add_namespace_entities(tree_node*, bitmap_head*) ../../gcc/cp/module.cc:12744 0xa29364 module_state::write(elf_out*, cpp_reader*) ../../gcc/cp/module.cc:17593 0xa2a9b8 finish_module_processing(cpp_reader*) ../../gcc/cp/module.cc:19857 0x9bdb5b c_parse_final_cleanups() ../../gcc/cp/decl2.c:5175 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. In module imported at Database-i.cpp:5:1: database: error: failed to read compiled module: No such file or directory database: note: compiled module file is ‘gcm.cache/database.gcm’ database: note: imports must be built before being imported database: fatal error: returning to the gate for a mechanical issue compilation terminated. make: *** [Makefile:55: gcm] Error 1 Commenting out the line std::vector<Employee> m_employees; makes the error go away, but will offcourse cause errors since m_employees cannot be found.
next reply other threads:[~2021-04-18 9:48 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-04-18 9:48 patrick.kox at commandoregel dot be [this message] 2021-06-20 9:03 ` [Bug c++/100134] [modules] ICE when using a vector in a module ensadc at mailnesia dot com 2022-03-10 14:49 ` sandipan.mohanty at gmail dot com 2022-04-06 7:47 ` sandipan.mohanty at gmail dot com 2022-04-06 7:52 ` sandipan.mohanty at gmail dot com 2022-09-26 23:33 ` pinskia at gcc dot gnu.org 2022-09-26 23:34 ` johelegp at gmail dot com 2022-10-07 19:11 ` ppalka at gcc dot gnu.org 2022-10-11 19:03 ` cvs-commit at gcc dot gnu.org 2022-10-12 14:36 ` ppalka at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-100134-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).