merryhime/dynarmic

Compilation failure: "cannot take address of consteval function 'GetMaskAndExpect' outside of an immediate invocation"

PureTryOut opened this issue · 7 comments

src/dynarmic/frontend/decoder/decoder_detail.h:175:43: error: cannot take address of consteval function 'GetMaskAndExpect' outside of an immediate invocation
        constexpr auto mask = std::get<0>(GetMaskAndExpect(bitstring));
                                          ^
src/dynarmic/frontend/decoder/decoder_detail.h:48:27: note: declared here
    static consteval auto GetMaskAndExpect(std::array<char, opcode_bitsize> bitstring) {
                          ^
src/dynarmic/frontend/decoder/decoder_detail.h:176:45: error: cannot take address of consteval function 'GetMaskAndExpect' outside of an immediate invocation
        constexpr auto expect = std::get<1>(GetMaskAndExpect(bitstring));
                                            ^
src/dynarmic/frontend/decoder/decoder_detail.h:48:27: note: declared here
    static consteval auto GetMaskAndExpect(std::array<char, opcode_bitsize> bitstring) {
                          ^
2 errors generated.

Which compiler (+version) is affected?

This is currently with Clang 14.0.6 and the Musl libc

Reproduced this issue with both Clang 12.0.0 and Clang 14.0.6 on Windows
Marking the function as constexpr instead of consteval makes it work again.

Annoying. Not entirely sure where this issue is arising from; will change to constexpr.

Macdu commented

This looks like a bug in clang (dolphin-emu/dolphin#10973, although in this PR they said it was solved in clang 14.0). I think it comes from the fact that calling a consteval function outside of an immediate invocation was added later in the specification(see https://open-std.org/JTC1/SC22/WG21/docs/papers/2020/p1937r2.html).

Workaround pushed af51845.

workaround works fine with the same initial configuration