Skip to content

[clang][bytecode] Constexpr function never produces a constant expression #164995

@BobIsOnFire

Description

@BobIsOnFire

Minimal repro:

class A { public: static constexpr int get_value2() { return 1 + get_value(); } static constexpr int get_value() { return 1; } };
<source>:3:26: error: constexpr function never produces a constant expression [-Winvalid-constexpr] 3 | static constexpr int get_value2() { return 1 + get_value(); } | ^~~~~~~~~~ <source>:3:52: note: undefined function 'get_value' cannot be used in a constant expression 3 | static constexpr int get_value2() { return 1 + get_value(); } | ^ <source>:4:26: note: declared here 4 | static constexpr int get_value() { return 1; } | ^ 1 error generated. Compiler returned: 1 

https://godbolt.org/z/v7vsra1YG

Error disappears if I reorder methods.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:bytecodeIssues for the clang bytecode constexpr interpreter

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions