Commit 7bc60eb
committed
llama-context: fix build fails with
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-Werror=missing-braces
1 parent 6de8ed7 commit 7bc60eb
1 file changed
+7
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2798 | 2798 | | |
2799 | 2799 | | |
2800 | 2800 | | |
2801 | | - | |
| 2801 | + | |
2802 | 2802 | | |
2803 | 2803 | | |
2804 | 2804 | | |
| |||
2858 | 2858 | | |
2859 | 2859 | | |
2860 | 2860 | | |
2861 | | - | |
| 2861 | + | |
2862 | 2862 | | |
2863 | 2863 | | |
2864 | 2864 | | |
| |||
2867 | 2867 | | |
2868 | 2868 | | |
2869 | 2869 | | |
2870 | | - | |
| 2870 | + | |
2871 | 2871 | | |
2872 | 2872 | | |
2873 | 2873 | | |
2874 | 2874 | | |
2875 | 2875 | | |
2876 | | - | |
| 2876 | + | |
2877 | 2877 | | |
2878 | 2878 | | |
2879 | 2879 | | |
| |||
2882 | 2882 | | |
2883 | 2883 | | |
2884 | 2884 | | |
2885 | | - | |
| 2885 | + | |
2886 | 2886 | | |
2887 | 2887 | | |
2888 | 2888 | | |
| |||
2894 | 2894 | | |
2895 | 2895 | | |
2896 | 2896 | | |
2897 | | - | |
| 2897 | + | |
2898 | 2898 | | |
2899 | 2899 | | |
2900 | 2900 | | |
| |||
2903 | 2903 | | |
2904 | 2904 | | |
2905 | 2905 | | |
2906 | | - | |
| 2906 | + | |
2907 | 2907 | | |
2908 | 2908 | | |
2909 | 2909 | | |
| |||
0 commit comments