public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/30381]  New: ISHFTC() constant folding is broken.
@ 2007-01-05  6:04 brooks at gcc dot gnu dot org
  2007-01-05  6:57 ` [Bug fortran/30381] " brooks at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: brooks at gcc dot gnu dot org @ 2007-01-05  6:04 UTC (permalink / raw)
  To: gcc-bugs

According to example in the F95 standard, this program should output 5, if
given inputs of 2 and 3.  It does indeed do this.

  program shiftcirc
    integer i, j
    read(*,*) i, j
    write(*,*) ishftc( 3, i, j )
  end program

However, if we replace i and j with constants, things start breaking.  First:

  program shiftcirc
    write(*,*) ishftc( 3, 2, 3 )
  end program

This outputs -3, which is incorrect.  Worse, if we do this:

  program shiftcirc
    integer i
    read(*,*) i
    write(*,*) ishftc( 3, 2, i )
  end program

This gives an error on compilation:

debian-gfortran:~/test> ../bin-trunk/bin/gfortran ishftc.f90 -o ishftc
ishftc.f90:4.26:

  write(*,*) ishftc( 3, 2, i )
                         1
Error: Invalid third argument of ISHFTC at (1)


-- 
           Summary: ISHFTC() constant folding is broken.
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: wrong-code, rejects-valid
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: brooks at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30381


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

* [Bug fortran/30381] ISHFTC() constant folding is broken.
  2007-01-05  6:04 [Bug fortran/30381] New: ISHFTC() constant folding is broken brooks at gcc dot gnu dot org
@ 2007-01-05  6:57 ` brooks at gcc dot gnu dot org
  2007-01-10  5:46 ` brooks at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: brooks at gcc dot gnu dot org @ 2007-01-05  6:57 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from brooks at gcc dot gnu dot org  2007-01-05 06:57 -------
Currently testing a patch for this.


-- 

brooks at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |brooks at gcc dot gnu dot
                   |dot org                     |org
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2007-01-05 06:57:19
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30381


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

* [Bug fortran/30381] ISHFTC() constant folding is broken.
  2007-01-05  6:04 [Bug fortran/30381] New: ISHFTC() constant folding is broken brooks at gcc dot gnu dot org
  2007-01-05  6:57 ` [Bug fortran/30381] " brooks at gcc dot gnu dot org
@ 2007-01-10  5:46 ` brooks at gcc dot gnu dot org
  2007-01-10  5:58 ` [Bug fortran/30381] [4.1 and 4.2] " brooks at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: brooks at gcc dot gnu dot org @ 2007-01-10  5:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from brooks at gcc dot gnu dot org  2007-01-10 05:46 -------
Subject: Bug 30381

Author: brooks
Date: Wed Jan 10 05:46:13 2007
New Revision: 120634

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=120634
Log:
PR 30381
PR 30420
* fortran/simplify.c (convert_mpz_to_unsigned): New function.
        (convert_mpz_to_signed): New function, largely based on
        twos_complement().
        (twos_complement): Removed.
        (gfc_simplify_ibclr): Add conversions to and from an
        unsigned representation before bit-twiddling.
        (gfc_simplify_ibset): Same.
        (gfc_simplify_ishftc): Add checks for overly large
        constant arguments, only check the third argument if
        it's present, carry over high bits into the result as
        appropriate, and perform the final conversion back to
        a signed representation using the correct sign bit.
        (gfc_simplify_not): Removed unnecessary masking.
* testsuite/gfortran.dg/
        * chkbits.f90: Added IBCLR tests; test calls for
        different integer kinds.
        * ishft.f90: Renamed to ishft_1.f90...
        * ishft_1.f90: ...Renamed from ishft.f90.
        * ishft_2.f90: New test.
        * ishft_3.f90: New test.


Added:
    trunk/gcc/testsuite/gfortran.dg/ishft_1.f90
      - copied unchanged from r120594,
trunk/gcc/testsuite/gfortran.dg/ishft.f90
    trunk/gcc/testsuite/gfortran.dg/ishft_2.f90
    trunk/gcc/testsuite/gfortran.dg/ishft_3.f90
Removed:
    trunk/gcc/testsuite/gfortran.dg/ishft.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/simplify.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/chkbits.f90


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30381


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

* [Bug fortran/30381] [4.1 and 4.2] ISHFTC() constant folding is broken.
  2007-01-05  6:04 [Bug fortran/30381] New: ISHFTC() constant folding is broken brooks at gcc dot gnu dot org
  2007-01-05  6:57 ` [Bug fortran/30381] " brooks at gcc dot gnu dot org
  2007-01-10  5:46 ` brooks at gcc dot gnu dot org
@ 2007-01-10  5:58 ` brooks at gcc dot gnu dot org
  2007-02-10 16:22 ` fxcoudert at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: brooks at gcc dot gnu dot org @ 2007-01-10  5:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from brooks at gcc dot gnu dot org  2007-01-10 05:58 -------
Fixed on 4.3, as per above commit.


-- 

brooks at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|ISHFTC() constant folding is|[4.1 and 4.2] ISHFTC()
                   |broken.                     |constant folding is broken.


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30381


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

* [Bug fortran/30381] [4.1 and 4.2] ISHFTC() constant folding is broken.
  2007-01-05  6:04 [Bug fortran/30381] New: ISHFTC() constant folding is broken brooks at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2007-01-10  5:58 ` [Bug fortran/30381] [4.1 and 4.2] " brooks at gcc dot gnu dot org
@ 2007-02-10 16:22 ` fxcoudert at gcc dot gnu dot org
  2007-02-16 12:19 ` fxcoudert at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-02-10 16:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from fxcoudert at gcc dot gnu dot org  2007-02-10 16:22 -------
Would you have time to backport it? I don't know if it was approved for 4.2
also, but if it applies cleanly and regtest OK, I don't see a reason to hold
it.


-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.2.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30381


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

* [Bug fortran/30381] [4.1 and 4.2] ISHFTC() constant folding is broken.
  2007-01-05  6:04 [Bug fortran/30381] New: ISHFTC() constant folding is broken brooks at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2007-02-10 16:22 ` fxcoudert at gcc dot gnu dot org
@ 2007-02-16 12:19 ` fxcoudert at gcc dot gnu dot org
  2007-02-16 15:57 ` [Bug fortran/30381] [4.1 only] " fxcoudert at gcc dot gnu dot org
  2007-06-21 13:09 ` bardeau at iram dot fr
  6 siblings, 0 replies; 8+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-02-16 12:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from fxcoudert at gcc dot gnu dot org  2007-02-16 12:19 -------
Subject: Bug 30381

Author: fxcoudert
Date: Fri Feb 16 12:19:01 2007
New Revision: 122039

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=122039
Log:
2007-02-16  Francois-Xavier Coudert  <coudert@clipper.ens.fr>

        PR fortran/30720
        * trans-array.c (gfc_trans_create_temp_array): Remove use of the
        function argument. Always generate code for negative extent.
        Simplify said code.
        * trans-array.h (gfc_trans_create_temp_array): Change prototype.
        * trans-expr.c (gfc_conv_function_call): Remove use of last argument
        of gfc_trans_create_temp_array.
        * trans-intrinsic.c (gfc_conv_intrinsic_array_transfer): Likewise.
        * trans-stmt.c (gfc_conv_elemental_dependencies): Likewise.

2007-02-16  Francois-Xavier Coudert  <coudert@clipper.ens.fr>

        PR fortran/30611
        * trans-intrinsic.c (gfc_conv_intrinsic_repeat): Evaluate
        arguments only once. Generate check that NCOPIES argument is not
        negative.

2007-02-16  Thomas Koenig  <Thomas.Koenig@online.de>

        PR libfortran/30389
        * gfortran.h:  Remove gfc_simplify_init_1.
        * arith.h:  Remove third argument from gfc_compare_string.
        * arith.c(gfc_compare_expression):  Remove third argument
        from call to gfc_compare_string.
        (gfc_compare_string):  Remove third argument xcoll_table.
        Remove use of xcoll_table.
        * misc.c(gfc_init_1):  Remove call to gfc_simplify_init_1.
        * simplify.c(ascii_table):  Remove.
        (xascii_table): Likewise.
        (gfc_simplify_achar):  ICE if extract_int fails.  Remove use of
        ascii_table.  Warn if -Wsurprising and value < 0 or > 127.
        (gfc_simplify_char):  ICE if extract_int fails. Error if
        value < 0 or value > 255.
        (gfc_simplify_iachar):  Remove use of xascii_table.
        Char values outside of 0..255 are an ICE.
        (gfc_simplify_lge):  Remove use of xascii_table.
        (gfc_simplify_lgt):  Likewise.
        (gfc_simplify_lle):  Likewise.
        (gfc_simplify_llt):  Likewise.
        (invert_table):  Remove.
        (gfc_simplify_init_1):  Remove.

2007-02-16  Brooks Moses  <brooks.moses@codesourcery.com>

        PR 30381
        PR 30420
        * simplify.c (convert_mpz_to_unsigned): New function.
        (convert_mpz_to_signed): New function, largely based on
        twos_complement().
        (twos_complement): Removed.
        (gfc_simplify_ibclr): Add conversions to and from an
        unsigned representation before bit-twiddling.
        (gfc_simplify_ibset): Same.
        (gfc_simplify_ishftc): Add checks for overly large
        constant arguments, only check the third argument if
        it's present, carry over high bits into the result as
        appropriate, and perform the final conversion back to
        a signed representation using the correct sign bit.
        (gfc_simplify_not): Removed unnecessary masking.

2007-02-16  Francois-Xavier Coudert  <coudert@clipper.ens.fr>

        PR fortran/30720
        * gfortran.dg/array_function_1.f90: New test.

2007-02-16  Francois-Xavier Coudert  <coudert@clipper.ens.fr>

        PR fortran/30611
        * gcc/testsuite/gfortran.dg/repeat_1.f90: New test.

2007-02-16  Thomas Koenig  <Thomas.Koenig@online.de>

        PR libfortran/30389
        * gfortran.dg/achar_2.f90:  New test.
        * gfortran.dg/achar_3.f90:  New test.

2007-02-16  Brooks Moses  <brooks.moses@codesourcery.com>

        * gfortran.dg/chkbits.f90: Added IBCLR tests; test calls
        for different integer kinds.
        * gfortran.dg/ishft.f90: Renamed to ishft_1.f90...
        * gfortran.dg/ishft_1.f90: ...Renamed from ishft.f90.
        * gfortran.dg/ishft_2.f90: New test.
        * gfortran.dg/ishft_3.f90: New test.

2007-02-16  Francois-Xavier Coudert  <coudert@clipper.ens.fr>

        PR fortran/30611
        * intrinsics/string_intrinsics.c (string_repeat): Don't check
        if ncopies is negative.

Added:
    branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/achar_2.f90
      - copied unchanged from r121255,
trunk/gcc/testsuite/gfortran.dg/achar_2.f90
    branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/achar_3.f90
      - copied unchanged from r121255,
trunk/gcc/testsuite/gfortran.dg/achar_3.f90
    branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/array_function_1.f90
      - copied unchanged from r121773,
trunk/gcc/testsuite/gfortran.dg/array_function_1.f90
    branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/ishft_1.f90
      - copied unchanged from r120634,
trunk/gcc/testsuite/gfortran.dg/ishft_1.f90
    branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/ishft_2.f90
      - copied unchanged from r120634,
trunk/gcc/testsuite/gfortran.dg/ishft_2.f90
    branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/ishft_3.f90
      - copied unchanged from r120634,
trunk/gcc/testsuite/gfortran.dg/ishft_3.f90
    branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/repeat_1.f90
      - copied unchanged from r121581,
trunk/gcc/testsuite/gfortran.dg/repeat_1.f90
Removed:
    branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/ishft.f90
Modified:
    branches/gcc-4_2-branch/gcc/fortran/ChangeLog
    branches/gcc-4_2-branch/gcc/fortran/arith.c
    branches/gcc-4_2-branch/gcc/fortran/arith.h
    branches/gcc-4_2-branch/gcc/fortran/gfortran.h
    branches/gcc-4_2-branch/gcc/fortran/misc.c
    branches/gcc-4_2-branch/gcc/fortran/simplify.c
    branches/gcc-4_2-branch/gcc/fortran/trans-array.c
    branches/gcc-4_2-branch/gcc/fortran/trans-array.h
    branches/gcc-4_2-branch/gcc/fortran/trans-expr.c
    branches/gcc-4_2-branch/gcc/fortran/trans-intrinsic.c
    branches/gcc-4_2-branch/gcc/fortran/trans-stmt.c
    branches/gcc-4_2-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/chkbits.f90
    branches/gcc-4_2-branch/libgfortran/ChangeLog
    branches/gcc-4_2-branch/libgfortran/intrinsics/string_intrinsics.c


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30381


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

* [Bug fortran/30381] [4.1 only] ISHFTC() constant folding is broken.
  2007-01-05  6:04 [Bug fortran/30381] New: ISHFTC() constant folding is broken brooks at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2007-02-16 12:19 ` fxcoudert at gcc dot gnu dot org
@ 2007-02-16 15:57 ` fxcoudert at gcc dot gnu dot org
  2007-06-21 13:09 ` bardeau at iram dot fr
  6 siblings, 0 replies; 8+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-02-16 15:57 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from fxcoudert at gcc dot gnu dot org  2007-02-16 15:56 -------
Fixed on mainline and 4.2. Unless you really want to backport it to 4.1.3, I'm
closing this bug.


-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30381


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

* [Bug fortran/30381] [4.1 only] ISHFTC() constant folding is broken.
  2007-01-05  6:04 [Bug fortran/30381] New: ISHFTC() constant folding is broken brooks at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2007-02-16 15:57 ` [Bug fortran/30381] [4.1 only] " fxcoudert at gcc dot gnu dot org
@ 2007-06-21 13:09 ` bardeau at iram dot fr
  6 siblings, 0 replies; 8+ messages in thread
From: bardeau at iram dot fr @ 2007-06-21 13:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from bardeau at iram dot fr  2007-06-21 13:08 -------
(In reply to comment #6)
> Fixed on mainline and 4.2. Unless you really want to backport it to 4.1.3, I'm
> closing this bug.
> 

The bug still appears under cygwin with gcc 4.3:

program test
   integer*4 a
   a=1
   print *,"a = ", a
   print *,"ISHFTC(a,2,32) = ", ISHFTC(a,2,32)
   print *,"ISHFTC(a,2) = ", ISHFTC(a,2)
end

~> ./test.exe 
 a =            1
 ISHFTC(a,2,32) =            1
 ISHFTC(a,2) =            4

This happens only if A is INTEGER*4 or 8, and if 3rd argument is present. Also,
no problem under Linux.

~> uname -a
CYGWIN_NT-5.1 dhcp-bardeau 1.5.24(0.156/4/2) 2007-01-31 10:57 i686 Cygwin

~> gfortran -v
Using built-in specs.
Target: i686-pc-cygwin
Configured with: ../gcc43/configure --prefix=/usr/local/gfortran
--enable-languages=c,fortran --enable-bootstrap --enable-threads=posix
--enable-sjlj-exceptions --enable-version-specific-runtime-libs --enable-nls
--disable-libmudflap --disable-shared --disable-win32-registry
--with-system-zlib --enable-checking=release --enable-werror
--without-included-gettext --without-x --enable-libgomp
Thread model: posix
gcc version 4.3.0 20070512 (experimental)


Cheers,

Sebastien


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30381


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

end of thread, other threads:[~2007-06-21 13:09 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-05  6:04 [Bug fortran/30381] New: ISHFTC() constant folding is broken brooks at gcc dot gnu dot org
2007-01-05  6:57 ` [Bug fortran/30381] " brooks at gcc dot gnu dot org
2007-01-10  5:46 ` brooks at gcc dot gnu dot org
2007-01-10  5:58 ` [Bug fortran/30381] [4.1 and 4.2] " brooks at gcc dot gnu dot org
2007-02-10 16:22 ` fxcoudert at gcc dot gnu dot org
2007-02-16 12:19 ` fxcoudert at gcc dot gnu dot org
2007-02-16 15:57 ` [Bug fortran/30381] [4.1 only] " fxcoudert at gcc dot gnu dot org
2007-06-21 13:09 ` bardeau at iram dot fr

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