Skip to content

Exhaustive stack usage #43598

Open
Open
@apolukhin

Description

@apolukhin
Bugzilla Link 44253
Version trunk
OS Linux
CC @apolukhin,@davidbolvansky,@dwblaikie,@efriedma-quic,@francisvm,@zygoloid,@rjmccall

Extended Description

Consider the following example:

struct test {
    test(test&&);

    void Extend(test v);
    int data_[4096];
};


test test_func(test t) {
    t.Extend(static_cast<test&&>(t));
    t.Extend(static_cast<test&&>(t));
    return t;
}

With -std=c++11 -O2 flags Clang uses 32768 bytes of stack, GCC uses 16392 bytes.

Note that adding additional t.Extend(static_cast<test&&>(t)); results in stack usage growth for Clang, while GCC keeps using only 16392 bytes.

Godbolt playground: https://godbolt.org/z/MdaNfa

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillaclang:codegenIR generation bugs: mangling, exceptions, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions