public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/95656] New: Inconsistent output in compiling an undefined function
@ 2020-06-12 14:13 haoxintu at gmail dot com
  2020-06-12 14:21 ` [Bug c++/95656] " jakub at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: haoxintu at gmail dot com @ 2020-06-12 14:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95656

            Bug ID: 95656
           Summary: Inconsistent output in compiling an undefined function
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: haoxintu at gmail dot com
  Target Milestone: ---

This code bug.cc

#include<iostream>
int main(){
    int a ();
    std::cout << a << std::endl;
    return 0;
}

In GCC-trunk without "-fsanitize=undefined"

$g++ bug.cc ; ./a.out
1

$g++-trunk -fsanitize=undefined bug.cc
/tmp/ccm15L4R.o: In function `main':
bug.cc:(.text+0x8f): undefined reference to `a()'
collect2: error: ld returned 1 exit status

While in GCC-5

$g++-5 bug.cc ; ./a.out
1
$g++-5 -fsanitize=undefined bug.cc ; ./a.out
1

My GCC versions are

$g++-trunk --version
g++ (GCC) 11.0.0 20200526 (experimental)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$g++-5 --version
g++-5 (Ubuntu 5.5.0-12ubuntu6~18.04) 5.5.0 20171010
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I also tested bug.cc in clang, it compiles well and output "1" whether adding
"-fsanitize=undefined" or not.

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

end of thread, other threads:[~2023-12-10 23:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-12 14:13 [Bug c++/95656] New: Inconsistent output in compiling an undefined function haoxintu at gmail dot com
2020-06-12 14:21 ` [Bug c++/95656] " jakub at gcc dot gnu.org
2020-06-14 20:21 ` pinskia at gcc dot gnu.org
2023-12-10 23:47 ` pinskia at gcc dot gnu.org
2023-12-10 23:48 ` pinskia at gcc dot gnu.org
2023-12-10 23:49 ` pinskia at gcc dot gnu.org

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).