Skip to content

Release build with AVM_WARNINGS_ARE_ERRORS=ON fails on an unused variable in module.h #2448

Open

Description

@bettio

Found while reviewing #2357; pre-existing (module.h is not changed by #2357). Configuring with -DCMAKE_BUILD_TYPE=Release -DAVM_WARNINGS_ARE_ERRORS=ON does not build, with gcc 15.2 and clang 21.1 alike:

src/libAtomVM/module.h:367:9: error: unused variable 'funs_count' [-Werror=unused-variable]

The error repeats for every translation unit that includes module.h. Debug builds, and the CI builds (which do not set CMAKE_BUILD_TYPE), are fine.

Cause: module_get_fun_arity_old_index_uniq (src/libAtomVM/module.h:364-376) reads funs_count only to check it in assert(fun_index < funs_count). A Release build defines NDEBUG, the assert disappears, and the variable becomes unused in a static inline function in a header.

Fix: mark it with UNUSED(funs_count) after the assert, or keep the read inside the assert (assert(fun_index < (int) READ_32_UNALIGNED(table_data + 8))), and add a Release + AVM_WARNINGS_ARE_ERRORS=ON configuration to CI so that this cannot come back.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions