Skip to content

Assert error on enum type_kind_t reflection when compiling with msvc x86 #1817

@AdjWang

Description

@AdjWang

Describe the bug
Assertion location:

ecs_assert(!(last_value > 0 &&

Called from:

world.component<type_kind_t>("flecs::meta::type_kind");

To Reproduce

Source tree:

.
├── CMakeLists.txt
├── flecs-4.1.1
└── main.cc

CMakeLists.txt

cmake_minimum_required(VERSION 3.28)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

project(flecs_test C CXX)

add_subdirectory(flecs-4.1.1)

add_executable(test main.cc)
target_link_libraries(test PRIVATE flecs::flecs_static)

main.cc

// Working if disables enum reflection.
// #define FLECS_CPP_NO_ENUM_REFLECTION
#include "flecs.h"

int main() {
    flecs::world w;
    return 0;
}

Compile:

cmake -B build -G "Visual Studio 17 2022" -T host=x86 -A win32
cmake --build ./build

Error:

› .\build\Debug\test.exe
fatal: enum.hpp: 351: assert(!(last_value > 0 && v < std::numeric_limits<U>::min() + last_value)): Signed integer enums causes integer overflow when recording offset from high positive to low negative. Consider using unsigned integers as underlying type. (UNSUPPORTED)

Additional context
Compiler version:

› cl
Microsoft (R) C/C++ Optimizing Compiler Version 19.44.35213 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

usage: cl [ option... ] filename... [ /link linkoption... ]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions