public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100134] New: ICE when using a vector in a mdoule
@ 2021-04-18  9:48 patrick.kox at commandoregel dot be
  2021-06-20  9:03 ` [Bug c++/100134] [modules] ICE when using a vector in a module ensadc at mailnesia dot com
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: patrick.kox at commandoregel dot be @ 2021-04-18  9:48 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-10-12 14:36 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-18  9:48 [Bug c++/100134] New: ICE when using a vector in a mdoule patrick.kox at commandoregel dot be
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

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