Skip to content

bogus warning -Wunused-but-set-variable compiling with clang -DNDEBUG #167361

@j4reporting

Description

@j4reporting

this code generates a warning when compiled with clang and -DNDEBUG

pr_edict.c:886:6: error: variable 'free_edicts_count' set but not used [-Werror,-Wunused-but-set-variable]
886 | int free_edicts_count = 0;
| ^
../Quake/pr_edict.c:887:6: error: variable 'free_list_count' set but not used [-Werror,-Wunused-but-set-variable]
887 | int free_list_count = 0;
| ^
2 errors generated.

changing
free_edicts_count++; to free_edicts_count = free_edicts_count + 1;
free_list_count++; to free_list_count = free_list_count +1;

prevents the warning.

compiling w/o -DNDEBUG prevents the warning because of the assert in line 921
assert (free_list_count == free_edicts_count);

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions