Skip to content

MSVC: exponential compile time and C1060 "compiler is out of heap space" #715

Description

@dornbirndevelops

Summary

I tried to update from boost-ext/sml commit 2e228bb to the current master.
MSVC failed to compile my project with error C1060 "compiler is out of heap space".

During my investigation, I could narrow down the issue pattern to a large amount of different dependencies being passed to boost::sml::sms constructor (see Reproducible example).
A git bisect showed that the issue got introduced with commit f9b00b3.

Reproducible example

The state machine itself in this example does not do much. Only the number of constructor arguments varies.

mre.cpp

#include <boost/sml.hpp>

#include <tuple>
#include <utility>

#ifndef NDEPS
#define NDEPS 28
#endif

template <int>
struct Dep {};

struct Event {};
struct Idle {};
struct Done {};

struct Action {
    void operator()(Dep<0>&) const {}
};

struct Machine {
    auto operator()() const
    {
        using namespace boost::sml;
        return make_transition_table(*state<Idle> + event<Event> / Action{} = state<Done>);
    }
};

template <int... Ns>
void build(std::integer_sequence<int, Ns...>)
{
    std::tuple<Dep<Ns>...> deps;
    boost::sml::sm<Machine> sm{std::get<Ns>(deps)...};
    sm.process_event(Event{});
}

int main() { build(std::make_integer_sequence<int, NDEPS>{}); }

Benchmarks

before ( = 8713d43):

Build started at 09:06...
1>------ Build started: Project: mre, Configuration: Debug x64 ------
1>mre.cpp
1>mre.vcxproj -> D:\dev\mre\build\Debug\mre.exe
========== Build: 1 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
========== Build completed at 09:06 and took 01.047 seconds ==========

after ( = f9b00b3):

Build started at 09:10...
1>------ Build started: Project: mre, Configuration: Debug x64 ------
1>mre.cpp
1>D:\dev\mre\sml\include\boost\sml.hpp(784,1): error C1060: compiler is out of heap space
1>(compiling source file '../mre.cpp')
1>Done building project "mre.vcxproj" -- FAILED
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========
========== Build completed at 09:10 and took 40.127 seconds ==========

master ( = 326b948):

Build started at 09:38...
1>------ Build started: Project: mre, Configuration: Debug x64 ------
1>mre.cpp
1>D:\dev\mre\sml\include\boost\sml.hpp(863,1): error C1060: compiler is out of heap space
1>(compiling source file '../mre.cpp')
1>Done building project "mre.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========
========== Build completed at 09:38 and took 16.418 seconds ==========

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions