asutton/clang

Incorrect codegen when using variables from a constexpr block in an injected function

Opened this issue · 0 comments

I'd expect the following code:

class MyClass {
    constexpr {
        int val = 0;
        -> [val] class { int getFirst() { return val; } }
        ++val;
        -> [val] class { int getSecond() { return val; } }
    }
};

to produce:

int MyClass::getFirst() { return 0; }
int MyClass::getSecond() { return 1; }

However both functions generate the same code: return MyClass::val;.