Skip to content

Compile bug: Parameter type truncation warning under Clang at (uint32_t)abs(o.val_i64) #15374

@kaetemi

Description

@kaetemi

Git commit

4d19698

Operating systems

Linux

GGML backends

CUDA

Problem description & steps to reproduce

Build warning under Clang

First Bad Commit

No response

Compile command

mkdir build_cuda
cd build_cuda
CC=clang CXX=clang++ cmake -G Ninja -DGGML_CUDA=ON -DLLAMA_CURL=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-O2" -DCMAKE_CXX_FLAGS="-O2" ..
ninja llama-server

Relevant log output

/home/kaetemi/llama.cpp/src/llama-quant.cpp:656:66: warning: absolute value function 'abs' given an argument of type 'const int64_t' (aka 'const long') but has parameter of type 'int' which may cause truncation of value [-Wabsolute-value]
  656 |                 gguf_set_val_u32(ctx_out.get(), o.key, (uint32_t)abs(o.val_i64));
      |                                                                  ^
/home/kaetemi/llama.cpp/src/llama-quant.cpp:656:66: note: use function 'std::abs' instead
  656 |                 gguf_set_val_u32(ctx_out.get(), o.key, (uint32_t)abs(o.val_i64));
      |                                                                  ^~~
      |                                                                  std::abs
1 warning generated.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions