From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AF8D6393BC2C; Sun, 18 Apr 2021 09:48:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AF8D6393BC2C From: "patrick.kox at commandoregel dot be" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: patrick.kox at commandoregel dot be X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Apr 2021 09:48:16 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100134 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 Ma= rc 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): =3D=3D=3D export module database; import; import; 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::stri= ng& lastName); Employee& getEmployee(int employeeNumber); Employee& getEmployee(const std::string& firstName, const std::stri= ng& lastName); void displayAll()const; void displayCurrent()const; void displayFormer()const; private: std::vector m_employees; int m_nextEmployeeNumber{FirstEmployeeNumber}; }; } =3D=3D=3D And the file Database-i.cpp (called Database.cpp in the book) =3D=3D=3D module database; import; 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()=3D=3DemployeeNumber) { 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(); } } } } =3D=3D=3D 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 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 =E2=80=98gcm.cache/database.gcm=E2= =80=99 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 m_employees; makes the error = go away, but will offcourse cause errors since m_employees cannot be found.=