seanbaxter / circle

The compiler is available for download. Get it!
http://www.circle-lang.org/
2.42k stars 74 forks source link

Circle crashes during compilation when: constexpr function used in intialization, using uint8_t and edition_2023 #168

Open cmarcelo opened 1 year ago

cmarcelo commented 1 year ago

This is a narrowed down version of the original code. Circle build 195. Blind guess here is compile time evaluation is getting tripped by uint8_t somehow...?

// If not using edition_2023, compiles fine.
#feature on edition_2023

#include <array>
#include <iostream>

enum class Op {
  MOV,
};

// If unsigned is used instead, compiles fine.
//using u8 = unsigned

using u8 = uint8_t;

constexpr std::array!<Op, 256> create_opcode_table() {
    std::array!<Op, 256> arr{};
    u8 start = 0b10001000;
    for (u8 i = 0; i < 4; i++)
        arr[start + i] = Op::MOV;
    return arr;
}

constexpr auto opcode_table = create_opcode_table();

int main() {
    std::cout << opcode_table.size() << "\n";
    return 0;
}