public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libfortran/99191] New: sanitizer detects undefined behaviour in libgfortran
@ 2021-02-22  9:21 zeccav at gmail dot com
  2021-02-22 16:02 ` [Bug libfortran/99191] " dominiq at lps dot ens.fr
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: zeccav at gmail dot com @ 2021-02-22  9:21 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 99191
           Summary: sanitizer detects undefined behaviour in libgfortran
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libfortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zeccav at gmail dot com
  Target Milestone: ---

! from pr66311.f90
! must be compiled and run with sanitized libgfortran
!../../../gcc-150221/libgfortran/io/write.c:835:7: runtime error: negation of
0x80000000000000000000000000000000 cannot be represented in type '__int128';
cast to an unsigned type to negate this value to itself
!../../../gcc-150221/libgfortran/runtime/string.c:199:11: runtime error:
negation of 0x80000000000000000000000000000000 cannot be represented in type
'__int128'; cast to an unsigned type to negate this value to itself
      use iso_fortran_env, only : ikinds => integer_kinds

      integer, parameter :: k = ikinds(size(ikinds))

      write(*,*) -huge(0_k)-1

      end

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

* [Bug libfortran/99191] sanitizer detects undefined behaviour in libgfortran
  2021-02-22  9:21 [Bug libfortran/99191] New: sanitizer detects undefined behaviour in libgfortran zeccav at gmail dot com
@ 2021-02-22 16:02 ` dominiq at lps dot ens.fr
  2021-02-23  8:52 ` marxin at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: dominiq at lps dot ens.fr @ 2021-02-22 16:02 UTC (permalink / raw)
  To: gcc-bugs

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

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-02-22
             Status|UNCONFIRMED                 |NEW

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

* [Bug libfortran/99191] sanitizer detects undefined behaviour in libgfortran
  2021-02-22  9:21 [Bug libfortran/99191] New: sanitizer detects undefined behaviour in libgfortran zeccav at gmail dot com
  2021-02-22 16:02 ` [Bug libfortran/99191] " dominiq at lps dot ens.fr
@ 2021-02-23  8:52 ` marxin at gcc dot gnu.org
  2021-12-25 13:04 ` fxcoudert at gcc dot gnu.org
  2021-12-25 14:57 ` fxcoudert at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-02-23  8:52 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Good, I can confirm that. The code contains a comment about it:

  if (n < 0)
    {
      negative = 1;
      t = -n; /*must use unsigned to protect from overflow*/
    }

Full back-trace:

/home/marxin/Programming/gcc2/libgfortran/io/write.c:835:7: runtime error:
negation of 0x80000000000000000000000000000000 cannot be represented in type
'__int128'; cast to an unsigned type to negate this value to itself
    #0 0x7ffff7844eec in write_decimal
/home/marxin/Programming/gcc2/libgfortran/io/write.c:835
    #1 0x7ffff7846d56 in write_integer
/home/marxin/Programming/gcc2/libgfortran/io/write.c:1369
    #2 0x7ffff7849b34 in list_formatted_write_scalar
/home/marxin/Programming/gcc2/libgfortran/io/write.c:1894
    #3 0x7ffff784a5eb in _gfortrani_list_formatted_write
/home/marxin/Programming/gcc2/libgfortran/io/write.c:1972
    #4 0x7ffff7812440 in wrap_scalar_transfer
/home/marxin/Programming/gcc2/libgfortran/io/transfer.c:2382
    #5 0x7ffff7812487 in _gfortran_transfer_integer
/home/marxin/Programming/gcc2/libgfortran/io/transfer.c:2393
    #6 0x7ffff78124b7 in _gfortran_transfer_integer_write
/home/marxin/Programming/gcc2/libgfortran/io/transfer.c:2399
    #7 0x400873 in check.0 (/home/marxin/Programming/testcases/a.out+0x400873)
    #8 0x4008b0 in MAIN__ (/home/marxin/Programming/testcases/a.out+0x4008b0)
    #9 0x4008e7 in main (/home/marxin/Programming/testcases/a.out+0x4008e7)
    #10 0x7ffff54edb24 in __libc_start_main (/lib64/libc.so.6+0x27b24)
    #11 0x40072d in _start (/home/marxin/Programming/testcases/a.out+0x40072d)

@Janne: Can you please take a look?

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

* [Bug libfortran/99191] sanitizer detects undefined behaviour in libgfortran
  2021-02-22  9:21 [Bug libfortran/99191] New: sanitizer detects undefined behaviour in libgfortran zeccav at gmail dot com
  2021-02-22 16:02 ` [Bug libfortran/99191] " dominiq at lps dot ens.fr
  2021-02-23  8:52 ` marxin at gcc dot gnu.org
@ 2021-12-25 13:04 ` fxcoudert at gcc dot gnu.org
  2021-12-25 14:57 ` fxcoudert at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: fxcoudert at gcc dot gnu.org @ 2021-12-25 13:04 UTC (permalink / raw)
  To: gcc-bugs

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

Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> changed:

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

--- Comment #2 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> ---
Will be fixed by patch at
https://gcc.gnu.org/pipermail/fortran/2021-December/057218.html

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

* [Bug libfortran/99191] sanitizer detects undefined behaviour in libgfortran
  2021-02-22  9:21 [Bug libfortran/99191] New: sanitizer detects undefined behaviour in libgfortran zeccav at gmail dot com
                   ` (2 preceding siblings ...)
  2021-12-25 13:04 ` fxcoudert at gcc dot gnu.org
@ 2021-12-25 14:57 ` fxcoudert at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: fxcoudert at gcc dot gnu.org @ 2021-12-25 14:57 UTC (permalink / raw)
  To: gcc-bugs

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

Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |12.0
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #3 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> ---
Fixed.

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

end of thread, other threads:[~2021-12-25 14:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-22  9:21 [Bug libfortran/99191] New: sanitizer detects undefined behaviour in libgfortran zeccav at gmail dot com
2021-02-22 16:02 ` [Bug libfortran/99191] " dominiq at lps dot ens.fr
2021-02-23  8:52 ` marxin at gcc dot gnu.org
2021-12-25 13:04 ` fxcoudert at gcc dot gnu.org
2021-12-25 14:57 ` fxcoudert 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).