Skip to content

build: fix const correctness in ggml-bitnet-mad#418

Open
darsh7807 wants to merge 1 commit intomicrosoft:mainfrom
darsh7807:codex/fix-compiler-const-y-col
Open

build: fix const correctness in ggml-bitnet-mad#418
darsh7807 wants to merge 1 commit intomicrosoft:mainfrom
darsh7807:codex/fix-compiler-const-y-col

Conversation

@darsh7807
Copy link

Summary

Fix a clang compiler error in src/ggml-bitnet-mad.cpp caused by dropping const qualification from a pointer derived from const int8_t * y.

Root cause

y is declared as const int8_t *, so y + col * by is also const int8_t *. The code assigned that expression to int8_t * y_col, which discards const qualification and fails to compile on clang.

Change

  • Change int8_t * y_col to const int8_t * y_col

Verification

  • Ran a targeted syntax check with Apple clang on macOS arm64:
clang++ -std=c++17 -fsyntax-only -Iinclude -I./src -I./3rdparty/llama.cpp -I./3rdparty/llama.cpp/include -I./3rdparty/llama.cpp/ggml/include -I./3rdparty/llama.cpp/ggml/src src/ggml-bitnet-mad.cpp
  • Full CMake configure in the repo is currently blocked by the separate open issue #378 (include/bitnet-lut-kernels.h missing), so validation here was limited to the affected translation unit.

Closes #407

@darsh7807
Copy link
Author

Verified locally on macOS arm64 by forcing syntax checking of the AVX2 branch.

On clean main:

clang++ -target x86_64-apple-darwin -D__AVX2__ -std=c++17 -fsyntax-only 
  -Iinclude -I./src -I./3rdparty/llama.cpp -I./3rdparty/llama.cpp/include 
  -I./3rdparty/llama.cpp/ggml/include -I./3rdparty/llama.cpp/ggml/src 
  src/ggml-bitnet-mad.cpp

This reproduces:

src/ggml-bitnet-mad.cpp:811:18: error: cannot initialize a variable of type 'int8_t *' with an rvalue of type 'const int8_t *'

On this branch, the same command succeeds after changing y_col to const int8_t *.

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.

Compiler error

1 participant