anthropics / anthropics/claudes-c-compiler
bug: void expression as function argument
- Ngôn ngữ chính
- Rust
- Star
- 2.8k
- Fork
- 247
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
### Description
CCC compiles code where a `void` expression is passed as a function argument without producing a diagnostic.
### Reproducer
``` c
#include
void void_fn() {
printf("Hello, World!\n");
}
int main() {
printf("%d\n", void_fn());
return 0;
}
```
### Expected Behavior
The C language specification on function calls (C11 6.5.2.2 paragraph 2) states that:
> Each argument shall have a type such that its value may be assigned to an object with the unqualified version of the type of its corresponding parameter
As void does not have a value, this should produce a diagnostic.
Clang and GCC both produce an error:
`error: invalid use of void expression`
### Actual Behavior
CCC compiles silently and produces a binary.
Executing the binary will print:
```
Hello, World!
14
```
The integer printed by `main` is the length of the string printed by `void_fn`.
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Đánh giá
Issue này chưa được đánh giá.