clang icon indicating copy to clipboard operation
clang copied to clipboard

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

Open hamzasood opened this issue 7 years ago • 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;.

hamzasood avatar Jul 28 '17 13:07 hamzasood