Skip to content

fix: change y_col to const int8_t pointer for better type safety - this is needed for intel mac setup using conda#483

Closed
DenisValeev wants to merge 1 commit intomicrosoft:mainfrom
DenisValeev:macbook-intel-setup
Closed

fix: change y_col to const int8_t pointer for better type safety - this is needed for intel mac setup using conda#483
DenisValeev wants to merge 1 commit intomicrosoft:mainfrom
DenisValeev:macbook-intel-setup

Conversation

@DenisValeev
Copy link

@DenisValeev DenisValeev commented Mar 17, 2026

hi, a summary of what this fixes:

PR Description: Fix const-correctness in ggml-bitnet-mad.cpp for Clang compatibility

Summary

This PR fixes a build-breaking compilation error on macOS (Apple Clang) by correctly qualifying y_col as a const pointer in src/ggml-bitnet-mad.cpp.

The Problem

When building on macOS using Apple Clang (version 17.0.0+), the compiler throws the following error:

error: cannot initialize a variable of type 'int8_t *' (aka 'signed char *') with an rvalue of type 'const int8_t *' (aka 'const signed char *')

This occurs because the variable y is passed or cast as a const pointer. Performing pointer arithmetic on it (e.g., y + col * by) results in a const pointer. Assigning this result to a non-const int8_t * y_col violates C++ type safety by implicitly discarding the const qualifier.

While some versions of GCC might only issue a warning, modern Clang—especially on Apple Silicon—treats this as a fatal error by default or under strict build flags.

The Fix

The variable y_col is only used for read operations in the subsequent logic. By changing the declaration to const int8_t * y_col, we:

  1. Resolve the compilation error on macOS/Clang.
  2. Ensure const-correctness, preventing accidental writes to read-only memory.
  3. Maintain compatibility across different compiler toolchains (GCC, Clang, MSVC).

…is is needed for intel mac setup using conda
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.

1 participant