codegen: an `array[N] ptr array[M] T` argument is declared as `T* a_p)[M]`
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 57/100
Hướng nghiên cứu
Read internal/cgen/expr.go around lines 611–620 and 649–678, where the issue identifies the type handling and declarator dimensions. Use the provided Wuffs repro to generate C, then check that the result is a valid declarator such as uint8_t (*a_p[2])[3] or that generation reports an error. Confirm the generated C compiles with a C compiler.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Hi,
General context of this work is in #188, including the AI-disclaimers.
No in-tree codec is affected by this issue; no std function has an argument that is an array of pointers to arrays. Claude judges the prospective risk of it as "low": the generated C does not compile, and the related nestings fail generation.
The following is Sol 6.1's writeup of the issue. Includes a repro, the generated declarator, compile errors from gcc 13.3, clang 18, MSVC and clang-cl 18, a control that compiles, and generation errors for two other nestings. The cause is reasoned from source.
For an array[2] ptr array[3] base.u8 argument, cgen emits uint8_t* a_p)[3], with an unmatched parenthesis and no outer array dimension. writeCTypeName strips the outer arrays before recognizing the pointer to an array, but writes the closing parenthesis and dimensions from the full type.
Minimal repro:
pub struct repro?(
buf : array[4] base.u8,
)
pub func repro.f!(p: array[2] ptr array[3] base.u8) {
args.p[0][1] = 7
}
Actual: at b36a81d3, wuffs-c gen -package_name repro arr_ptr_arr.wuffs exits 0 with empty stderr. The prototype is:
wuffs_repro__repro__f(
wuffs_repro__repro* self,
uint8_t* a_p)[3]);
Compiling the amalgamation with WUFFS_IMPLEMENTATION defined fails with gcc 13.3 (-std=c99 -c, exit 1), clang 18 (exit 1), MSVC (cl /c, exit 2) and clang-cl 18 (exit 1):
arr_ptr_arr-release.c:7939:1: error: ‘wuffs_repro__repro__f’ declared as function returning an array
arr_ptr_arr-release.c:7941:21: error: expected declaration specifiers before ‘)’ token
arr_ptr_arr-release.c:7941:21: error: expected function body after function declarator
arr_ptr_arr-release.c(7941): error C2059: syntax error: ')'
arr_ptr_arr-release.c(7939): error C2090: function returns array
arr_ptr_arr-release.c(7941,21): error: expected function body after function declarator
Control: a ptr array[3] base.u8 argument, without the outer array, is emitted as uint8_t* a_p and compiles. Two other nestings fail generation: ptr array[2] ptr base.u8 and ptr ptr array[3] base.u8 arguments produce cannot convert Wuffs type "ptr array[2] ptr base.u8" to C and cannot convert Wuffs type "ptr ptr array[3] base.u8" to C.
Expected: either a valid declarator for an array of pointers to arrays, such as uint8_t (*a_p[2])[3], or a generation error.
Cause: the outer arrays are stripped into x, and the pointer-to-array case is recognized on x:
The closing parenthesis and dimensions are then written from n, the full type. The outer array shifts what x.Inner().Inner() refers to:
- Ngôn ngữ chính
- C
- Star
- 4.9k
- Fork
- 150
- Merge trung bình
- 4 ngày 1 giờ
- Pull request đã merge (30 ngày)
- 3
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của google/wuffs
-
codegen: `io_reader.match7` with an empty prefix shifts a `uint64_t` by 64 and reports a mismatchĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
soundness: an assignment to a `const` is accepted, and a `roarray` const is written in placeĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 67/100
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
containers/bubblewrap#826 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Vulkan: create_device reads the device extension list after freeing it (random crash at start)Đang mở
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 62/100
Revivedx/SavageWindRecomp#488 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
needs-device
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
feature/themes QA/No release-notes/exclude tests tests/missing-coverage tests/test-quality
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
brave/brave-browser#60971 ·
Maintainer thường phản hồi trong vòng 1 ngày