https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112826
Bug ID: 112826
Summary: gcc rejects the valid code and reports undefined
reference
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: jwzeng at nuaa dot edu.cn
Target Milestone: ---
Hi, the following code seems valid. Gcc rejects it while clang accepts.
Compiler explorer: https://godbolt.org/z/sPK9sYqc6
```c
$ cat test.c
int* a();
static int b() { int *c = a();}
int main() {}
$
$ gcc test.c
/tmp/cchtt1Nc.o:test.c:function b: error: undefined reference to 'a'
collect2: error: ld returned 1 exit status
$
$ clang test.c
test.c:2:31: warning: non-void function does not return a value [-Wreturn-type]
2 | static int b() { int *c = a();}
| ^
1 warning generated.
$
$ gcc --version
gcc (GCC) 13.1.0
Copyright (C) 2023 Free Software Foundation, Inc.
$
$ clang --version
clang version 16.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
```