public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug sanitizer/100591] New: -fsanitize=undefined fails to detect undefined floating to integer conversion
@ 2021-05-13 18:02 schwab@linux-m68k.org
  2021-05-14  9:56 ` [Bug sanitizer/100591] " marxin at gcc dot gnu.org
  2021-05-14 10:07 ` marxin at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: schwab@linux-m68k.org @ 2021-05-13 18:02 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100591
           Summary: -fsanitize=undefined fails to detect undefined
                    floating to integer conversion
           Product: gcc
           Version: 10.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: sanitizer
          Assignee: unassigned at gcc dot gnu.org
          Reporter: schwab@linux-m68k.org
                CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
                    jakub at gcc dot gnu.org, kcc at gcc dot gnu.org, marxin at gcc dot gnu.org
  Target Milestone: ---

$ cat undef.c
#include <stdio.h>

volatile double d = 0.0/0.0;

int
main (void)
{
  printf ("%d\n", (int) d);
}
$ gcc -fsanitize=undefined undef.c 
$ ./a.out 
-2147483648

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

* [Bug sanitizer/100591] -fsanitize=undefined fails to detect undefined floating to integer conversion
  2021-05-13 18:02 [Bug sanitizer/100591] New: -fsanitize=undefined fails to detect undefined floating to integer conversion schwab@linux-m68k.org
@ 2021-05-14  9:56 ` marxin at gcc dot gnu.org
  2021-05-14 10:07 ` marxin at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-05-14  9:56 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-05-14
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
$ gcc pr100591.c -fsanitize=undefined -fsanitize=float-cast-overflow && ./a.out 
pr100591.c:8:3: runtime error: nan is outside the range of representable values
of type 'int'
-2147483648

-fsanitize=float-cast-overflow
...
Unlike other similar options, -fsanitize=float-cast-overflow is not enabled by
-fsanitize=undefined.
This option does not work well with "FE_INVALID" exceptions enabled.

@Jakub: Do you know why is it disabled by default? Note that clang enables it
with -fsanitize=undefined:

$ clang pr100591.c -fsanitize=undefined && ./a.out
pr100591.c:8:19: runtime error: nan is outside the range of representable
values of type 'int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior pr100591.c:8:19 in 
-2147483648

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

* [Bug sanitizer/100591] -fsanitize=undefined fails to detect undefined floating to integer conversion
  2021-05-13 18:02 [Bug sanitizer/100591] New: -fsanitize=undefined fails to detect undefined floating to integer conversion schwab@linux-m68k.org
  2021-05-14  9:56 ` [Bug sanitizer/100591] " marxin at gcc dot gnu.org
@ 2021-05-14 10:07 ` marxin at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-05-14 10:07 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

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

--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
Closing as invalid.

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

end of thread, other threads:[~2021-05-14 10:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-13 18:02 [Bug sanitizer/100591] New: -fsanitize=undefined fails to detect undefined floating to integer conversion schwab@linux-m68k.org
2021-05-14  9:56 ` [Bug sanitizer/100591] " marxin at gcc dot gnu.org
2021-05-14 10:07 ` marxin 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).