Why C++ compiles slowly

Simen kjaeraas simen.kjaras at gmail.com
Wed Aug 25 08:36:24 PDT 2010


Steven Schveighoffer <schveiguy at yahoo.com> wrote:

>> Pure might be worth stuffing in the symbol name, as the compiler may
>> optimize things differently for pure vs. non-pure(dirty?) code.
>> E.g. the result of a large, pure function that takes a while to compute
>> might be cached to prevent calling it twice.
>
> These are decisions made at the compilation stage, not the linking stage.

Absolutely. Now, you compile your module that uses a pure function foo in
another module, and the above optimization is used. Later, that module is
changed, and foo is changed to depend on some global state, and is thus
no longer pure. After compiling this one module, you link your project,
and the cached value is wrong, and boom! Nasal demons.

-- 
Simen


More information about the Digitalmars-d mailing list