[cfe-dev] boost delay.c consumes huge amounts of memory
Jason Haslam via cfe-dev
cfe-dev at lists.llvm.org
Tue Nov 10 15:16:14 PST 2015
> On Nov 10, 2015, at 2:53 PM, Richard Smith <richard at metafoo.co.uk> wrote:
>
> On Tue, Nov 10, 2015 at 10:11 AM, Jason Haslam via cfe-dev <cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org>> wrote:
> There’s a test file in boost at libs/preprocessor/doc/examples/delay.c that causes clang to quickly consume large amounts of memory. Has anybody seen this before? Is there some sort of workaround (like maybe a flag to limit macro expansion depth)? I couldn’t find an issue in the bug tracker.
>
> From that file:
> # /* The time complexity of DELAY(N) is O(2^N).
> # *
> # * Handy when recompiles are too fast to take a coffee break. :)
> # *
> # * Template metaprogramming can be used for implementing similar
> # * delays. Unfortunately template instantiation consumes memory,
> # * therefore compilers usually fail to fully compile long template
> # * based delays, because they run out of memory.
> # *
> # * On many compilers (e.g. g++, MSVC++), this macro takes only a
> # * small amount of memory to preprocess. On some compilers (e.g.
> # * MWCW), however, this macro seems to consume huge amounts of
> # * memory.
> The "problem" is likely to be that we're keeping track of all the macro expansions performed by this ridiculous code, so this will use 2^N memory as well as 2^N time. We don't have any way to turn that off. If you file a bug on this, it's likely to be resolved as invalid unless you can provide a good reason for why we should care about code that is deliberately trying to break the compiler.
Okay, thanks. I don’t necessarily care about this code or expect anything reasonable to happen. The issue arises when users blindly try to slurp up and analyze everything in a directory. The outcome isn’t very friendly (especially on Windows).
Jason
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20151110/77d24377/attachment.html>
More information about the cfe-dev
mailing list