gcc-14 把 -Wimplicit-int 也提成了 error。全库判过的 C 提交里有 45 条这么写(8 条 AC), 重新编译一遍:不放行全是 CE,放行后 45 条全部编译通过。最近一条因此 CE 的在 2026-09-28。 冒烟测试那条宽松度用例把 main 改成省略 int 的写法。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
79ca8ac3bd
commit
4c6f2e7611
2 files changed
+8
-6
No files matched your search
@@ -19,10 +19,11 @@ import { normalizeLanguage } from "@oj2/contract"
|
||||
const defaultEnv = ["LANG=en_US.UTF-8", "LANGUAGE=en_US:en", "LC_ALL=en_US.UTF-8"]
|
||||
|
||||
/**
|
||||
* gcc-14 起这四类老写法从 warning 提成了 error,而 `-w` 只关警告、压不住 error:
|
||||
* gcc-14 起这五类老写法从 warning 提成了 error,而 `-w` 只关警告、压不住 error:
|
||||
* 隐式函数声明(忘了 `#include <stdio.h>` 就用 printf)、int 与指针互赋、
|
||||
* 不兼容的指针类型、`int main` 里写不带值的 `return;`(全库 4 条,gcc-13 下能跑,
|
||||
* 放行后退出码不定,多半判运行时错误,说明会让补 return 0)。判题机镜像 2026-09 从 gcc-13 升到 14(见 docker/judge/),
|
||||
* 放行后退出码不定,多半判运行时错误,说明会让补 return 0)、省略 int 的
|
||||
* `main()`(全库判过的 45 条,其中 8 条 AC)。判题机镜像 2026-09 从 gcc-13 升到 14(见 docker/judge/),
|
||||
* 不加这几个开关的话,**一批历史题解和 20 篇 C 教程的示例会突然全部 CE**。
|
||||
*
|
||||
* 只给 C 加:C++ 那边这些本来就是 error,g++ 升版不改判定。
|
||||
@@ -30,7 +31,7 @@ const defaultEnv = ["LANG=en_US.UTF-8", "LANGUAGE=en_US:en", "LC_ALL=en_US.UTF-8
|
||||
* docs/c-tutorials/verify-code.sh 全量过一遍教程。
|
||||
*/
|
||||
const cLooseErrors =
|
||||
"-Wno-error=implicit-function-declaration -Wno-error=int-conversion -Wno-error=incompatible-pointer-types -Wno-error=return-mismatch"
|
||||
"-Wno-error=implicit-function-declaration -Wno-error=int-conversion -Wno-error=incompatible-pointer-types -Wno-error=return-mismatch -Wno-error=implicit-int"
|
||||
|
||||
export const languageConfigs: Record<string, Record<string, unknown>> = {
|
||||
C: {
|
||||
|
||||
@@ -67,16 +67,17 @@ int main(void) {
|
||||
}`,
|
||||
},
|
||||
{
|
||||
// gcc-14 把 int 函数里不带值的 return; 也提成了 error(-Wreturn-mismatch)
|
||||
// gcc-14 把 int 函数里不带值的 return;(-Wreturn-mismatch)、省略 int 的
|
||||
// main()(-Wimplicit-int)也提成了 error
|
||||
language: "C",
|
||||
name: "C 不带值的 return; 仍能过(gcc 宽松度)",
|
||||
name: "C 不带值的 return;、省略 int 的 main() 仍能过(gcc 宽松度)",
|
||||
expect: JudgeStatus.ACCEPTED,
|
||||
code: `#include <stdio.h>
|
||||
int check(int a) {
|
||||
if (a < 0) return;
|
||||
return a;
|
||||
}
|
||||
int main(void) {
|
||||
main(void) {
|
||||
int a, b;
|
||||
scanf("%d %d", &a, &b);
|
||||
printf("%d\\n", check(a) + b);
|
||||
|
||||
Reference in new issue
Block a user