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

* [Bug c++/95656] Inconsistent output in compiling an undefined function
  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 ` jakub at gcc dot gnu.org
  2020-06-14 20:21 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-06-12 14:21 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I don't see anything wrong on that.
You end up with essentially a != nullptr test, which is in some cases optimized
away, but during sanitization tests whether some address is non-NULL are
intentionally not optimized in case they would end up being NULL
(-fsanitize=undefined implies -fno-delete-null-pointer-checks).
You get the same result if you use -fno-delete-null-pointer-checks without
sanitization.

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

* [Bug c++/95656] Inconsistent output in compiling an undefined function
  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
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2020-06-14 20:21 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
As mentioned invalid.

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

* [Bug c++/95656] Inconsistent output in compiling an undefined function
  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
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-12-10 23:47 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |resence at parsoma dot net

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 112947 has been marked as a duplicate of this bug. ***

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

* [Bug c++/95656] Inconsistent output in compiling an undefined function
  2020-06-12 14:13 [Bug c++/95656] New: Inconsistent output in compiling an undefined function haoxintu at gmail dot com
                   ` (2 preceding siblings ...)
  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
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-12-10 23:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
* See also PR79265 and PR98109

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

* [Bug c++/95656] Inconsistent output in compiling an undefined function
  2020-06-12 14:13 [Bug c++/95656] New: Inconsistent output in compiling an undefined function haoxintu at gmail dot com
                   ` (3 preceding siblings ...)
  2023-12-10 23:48 ` pinskia at gcc dot gnu.org
@ 2023-12-10 23:49 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-12-10 23:49 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=101576

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
And see PR 101576 too.

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