public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/112826] New: gcc rejects the valid code and reports undefined reference
@ 2023-12-02 15:32 jwzeng at nuaa dot edu.cn
  2023-12-02 15:43 ` [Bug c/112826] " arsen at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: jwzeng at nuaa dot edu.cn @ 2023-12-02 15:32 UTC (permalink / raw)
  To: gcc-bugs

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
```

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-12-03  8:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-02 15:32 [Bug c/112826] New: gcc rejects the valid code and reports undefined reference jwzeng at nuaa dot edu.cn
2023-12-02 15:43 ` [Bug c/112826] " arsen at gcc dot gnu.org
2023-12-02 16:31 ` xry111 at gcc dot gnu.org
2023-12-02 22:43 ` pinskia at gcc dot gnu.org
2023-12-03  8:01 ` jwzeng at nuaa dot edu.cn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).