Skip to content

Conversation

@otegami
Copy link
Contributor

@otegami otegami commented Oct 21, 2025

ref: GH-16614

Why it failed

When compiling with strict compiler flags (-Wmissing-braces -Werror=missing-braces), the build fails with the following error:

cmake \
  -S . \
  -B ../llama.cpp.build \
  --preset=x64-linux-gcc-debug \
  -DCMAKE_INSTALL_PREFIX=/tmp/local \
  -DCMAKE_CXX_FLAGS="-Wmissing-braces -Werror=missing-braces" && \
cmake --build ../llama.cpp.build/
...
/home/otegami/work/cpp/llama.cpp/src/llama-context.cpp: In function ‘void llama_memory_breakdown_print(const llama_context*)’:
/home/otegami/work/cpp/llama.cpp/src/llama-context.cpp:2801:25: error: missing braces around initializer for ‘std::__array_traits<std::__cxx11::basic_string<char>, 9>::_Type’ {aka ‘std::__cxx11::basic_string<char> [9]’} [-Werror=missing-braces]
...

The issue is that std::array initialization requires double braces.

How to fix

This PR changes { 0 } to {{ 0 }} for std::array initialization.

This is part of a series of commits to fix missing braces warnings across the codebase.

  • Done: src/llama-batch.h
  • src/llama-context.cpp <- This PR is here.
  • tests/test-backend-ops.cpp
  • tests/test-gguf.cpp
  • tools/mtmd/clip.cpp

Benefits:

  • std::array is a struct containing a C-style array, requiring nested braces
  • Enables stricter compiler warnings to catch potential issues

ref: ggml-orgGH-16614

## Why it failed

When compiling with strict compiler flags (-Wmissing-braces -Werror=missing-braces), the build fails with the following error:

```
cmake \
  -S . \
  -B ../llama.cpp.build \
  --preset=x64-linux-gcc-debug \
  -DCMAKE_INSTALL_PREFIX=/tmp/local \
  -DCMAKE_CXX_FLAGS="-Wmissing-braces -Werror=missing-braces" && \
cmake --build ../llama.cpp.build/
...
/home/otegami/work/cpp/llama.cpp/src/llama-context.cpp: In function ‘void llama_memory_breakdown_print(const llama_context*)’:
/home/otegami/work/cpp/llama.cpp/src/llama-context.cpp:2801:25: error: missing braces around initializer for ‘std::__array_traits<std::__cxx11::basic_string<char>, 9>::_Type’ {aka ‘std::__cxx11::basic_string<char> [9]’} [-Werror=missing-braces]
...
```

The issue is that std::array initialization requires double braces.

## How to fix

This PR changes `{ 0 }` to `{{ 0 }}` for std::array initialization.

This is part of a series of commits to fix missing braces warnings across the codebase.
- Done: ~~src/llama-batch.h~~
- src/llama-context.cpp <- This PR is here.
- tests/test-backend-ops.cpp
- tests/test-gguf.cpp
- tools/mtmd/clip.cpp

Benefits:
- std::array is a struct containing a C-style array, requiring nested braces
- Enables stricter compiler warnings to catch potential issues
@otegami otegami requested a review from ggerganov as a code owner October 21, 2025 00:06
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