Skip to content

fix: const-correctness in ggml-bitnet-mad.cpp#422

Open
redhole-org wants to merge 1 commit intomicrosoft:mainfrom
redhole-org:fix/const-correctness-clangcl
Open

fix: const-correctness in ggml-bitnet-mad.cpp#422
redhole-org wants to merge 1 commit intomicrosoft:mainfrom
redhole-org:fix/const-correctness-clangcl

Conversation

@redhole-org
Copy link

Summary

  • y is declared as const int8_t * (line 794) but y_col on line 811 assigns to int8_t *, dropping the const qualifier
  • This compiles as a hard error on Clang with strict settings (e.g. ClangCL on Windows with -T ClangCL)

Fix

Changed int8_t * y_col = y + col * by;const int8_t * y_col = y + col * by;

Note: llama.cpp submodule also has issues

The 3rdparty/llama.cpp submodule (Eddie-Wang1120/llama.cpp branch merge-dev) has missing #include <chrono> in:

  • common/log.cpp (line 28 uses std::chrono::system_clock)
  • common/common.cpp (line 445 uses std::chrono::system_clock)

Both rely on transitive includes that work on GCC and Apple Clang but fail on ClangCL (Windows). That fix should be applied upstream in the llama.cpp fork.

Test plan

  • Built successfully on macOS ARM64 (LLVM Clang 20)
  • Built successfully on Linux x86_64 (Clang 18)
  • Built successfully on Windows x64 (ClangCL via Visual Studio 2022)

`y` is declared as `const int8_t *` (line 794) but `y_col` on line 811
drops the const qualifier by assigning to `int8_t *`. This is a
const-correctness violation that compiles as a hard error on Clang with
strict settings (e.g. ClangCL on Windows).

Additionally, the llama.cpp submodule has missing `#include <chrono>` in
`common/log.cpp` and `common/common.cpp` — both use
`std::chrono::system_clock` but rely on transitive includes that only
work on GCC/Apple Clang, not ClangCL. That fix should be applied to the
llama.cpp submodule (Eddie-Wang1120/llama.cpp branch merge-dev).
@ilhangrn
Copy link

Thanks, it helps but we need to update some more files with #include as mentioned here: #334

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants