[Bug fortran/96911] bug with Intrinsic shifta/shiftl/shiftr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96911 --- Comment #6 from zhen...@compiler-dev.com --- (In reply to kargl from comment #2) > (In reply to zhen.xu from comment #0) > > Dealing with Intrinsic shifta/shiftl/shiftr, gfortran refuses proper numbers > > in the code below and throws "Error: Integer too big for its kind". > > > > The code is checked with ifort. > > > > ---code-- > > program test > > print *, shifta(-128_1, 1); > > print *, shifta(-32768_2, 1); > > print *, shifta(-2147483648_4, 1); > > print *, shifta(-9223372036854775808_8, 1); > > > > print *, shiftl(-128_1, 1); > > print *, shiftl(-32768_2, 1); > > print *, shiftl(-2147483648_4, 1); > > print *, shiftl(-9223372036854775808_8, 1); > > > > print *, shiftr(-128_1, 1); > > print *, shiftr(-32768_2, 1); > > print *, shiftr(-2147483648_4, 1); > > print *, shiftr(-9223372036854775808_8, 1); > > > > end > > -- > > There are no negative integer withs gfortran. -128_1 is a unary minus > operator and 128_1 is a invalid operand. 128_1 would be greater than > huge(1_1). The only way to get the most "negative integer" is > to do -huge(1_1) - 1 (assuming twos-complement arithmetic applies). You are right! I made a mistake, please ignore my previous reply. The right testcase should be below and it throws out the same prompt. --- program testint integer(1) :: x = -128_1 print *, x end ---
[Bug fortran/96911] bug with Intrinsic shifta/shiftl/shiftr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96911 --- Comment #5 from zhen...@compiler-dev.com --- (In reply to kargl from comment #2) > (In reply to zhen.xu from comment #0) > > Dealing with Intrinsic shifta/shiftl/shiftr, gfortran refuses proper numbers > > in the code below and throws "Error: Integer too big for its kind". > > > > The code is checked with ifort. > > > > ---code-- > > program test > > print *, shifta(-128_1, 1); > > print *, shifta(-32768_2, 1); > > print *, shifta(-2147483648_4, 1); > > print *, shifta(-9223372036854775808_8, 1); > > > > print *, shiftl(-128_1, 1); > > print *, shiftl(-32768_2, 1); > > print *, shiftl(-2147483648_4, 1); > > print *, shiftl(-9223372036854775808_8, 1); > > > > print *, shiftr(-128_1, 1); > > print *, shiftr(-32768_2, 1); > > print *, shiftr(-2147483648_4, 1); > > print *, shiftr(-9223372036854775808_8, 1); > > > > end > > -- > > There are no negative integer withs gfortran. -128_1 is a unary minus > operator and 128_1 is a invalid operand. 128_1 would be greater than > huge(1_1). The only way to get the most "negative integer" is > to do -huge(1_1) - 1 (assuming twos-complement arithmetic applie You are right(In reply to anlauf from comment #1) > Error: Integer too big for its kind at (1). This check can be disabled with > the option '-fno-range-check' > > Why don't you read what gfortran is telling you, and acting appropriately? Sorry, I made a mistake. You are right. (In reply to anlauf from comment #1) > Error: Integer too big for its kind at (1). This check can be disabled with > the option '-fno-range-check' > > Why don't you read what gfortran is telling you, and acting appropriately? You are right! I made a mistake, please ignore my previous reply. The right testcase should be below and it throws out the same prompt. --- program testint integer(1) :: x = -128_1 print *, x end ---
[Bug fortran/96911] bug with Intrinsic shifta/shiftl/shiftr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96911 --- Comment #4 from zhen...@compiler-dev.com --- (In reply to kargl from comment #2) > (In reply to zhen.xu from comment #0) > > Dealing with Intrinsic shifta/shiftl/shiftr, gfortran refuses proper numbers > > in the code below and throws "Error: Integer too big for its kind". > > > > The code is checked with ifort. > > > > ---code-- > > program test > > print *, shifta(-128_1, 1); > > print *, shifta(-32768_2, 1); > > print *, shifta(-2147483648_4, 1); > > print *, shifta(-9223372036854775808_8, 1); > > > > print *, shiftl(-128_1, 1); > > print *, shiftl(-32768_2, 1); > > print *, shiftl(-2147483648_4, 1); > > print *, shiftl(-9223372036854775808_8, 1); > > > > print *, shiftr(-128_1, 1); > > print *, shiftr(-32768_2, 1); > > print *, shiftr(-2147483648_4, 1); > > print *, shiftr(-9223372036854775808_8, 1); > > > > end > > -- > > There are no negative integer withs gfortran. -128_1 is a unary minus > operator and 128_1 is a invalid operand. 128_1 would be greater than > huge(1_1). The only way to get the most "negative integer" is > to do -huge(1_1) - 1 (assuming twos-complement arithmetic applies). But how can the code below be compiled by gfortran well and print out -128 properly? program testint integer(1) :: x = -128 print *, x end
[Bug fortran/96911] bug with Intrinsic shifta/shiftl/shiftr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96911 --- Comment #3 from zhen...@compiler-dev.com --- (In reply to anlauf from comment #1) > Error: Integer too big for its kind at (1). This check can be disabled with > the option '-fno-range-check' > > Why don't you read what gfortran is telling you, and acting appropriately? The fact is -128 is surely not too big for integer(1). The below code is compiled by gfortran and can print out -128 properly. program testint integer(1) :: x = -128 print *, x end
[Bug fortran/96911] New: bug with Intrinsic shifta/shiftl/shiftr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96911 Bug ID: 96911 Summary: bug with Intrinsic shifta/shiftl/shiftr Product: gcc Version: 10.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: zhen...@compiler-dev.com Target Milestone: --- Dealing with Intrinsic shifta/shiftl/shiftr, gfortran refuses proper numbers in the code below and throws "Error: Integer too big for its kind". The code is checked with ifort. ---code-- program test print *, shifta(-128_1, 1); print *, shifta(-32768_2, 1); print *, shifta(-2147483648_4, 1); print *, shifta(-9223372036854775808_8, 1); print *, shiftl(-128_1, 1); print *, shiftl(-32768_2, 1); print *, shiftl(-2147483648_4, 1); print *, shiftl(-9223372036854775808_8, 1); print *, shiftr(-128_1, 1); print *, shiftr(-32768_2, 1); print *, shiftr(-2147483648_4, 1); print *, shiftr(-9223372036854775808_8, 1); end --
[Bug fortran/96890] New: Wrong answer with intrinsic IALL
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96890 Bug ID: 96890 Summary: Wrong answer with intrinsic IALL Product: gcc Version: 10.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: zhen...@compiler-dev.com Target Milestone: --- I got wrong answer with iall, only when all 3 parameters ARRAY/DIM/MASK are all present and the rank of array >1. ---test code--- program test_f90_intrinsics integer :: i, j, k integer, dimension(2) :: ia1 integer, dimension(2,2) :: ia2 integer, dimension(2,2,2) :: ia3 integer, dimension(2,2,2,2) :: ia4 logical, dimension(2) :: mask1 logical, dimension(2, 2) :: mask2 logical, dimension(2, 2, 2) :: mask3 logical, dimension(2, 2, 2, 2) :: mask4 data ia1 / 1, 2 / data ia2 / 1, 2, 3, 4 / data ia3 / 1, 2, 3, 4, 5, 6, 7, 8 / data ia4 / 1, 2, 3, 4, 5, 6, 7, 8, & 9, 10, 11, 12, 13, 14, 15, 16 / data mask1 / .true., .false. / data mask2 / .true., .false., .true., .false. / data mask3 / .true., .false., .true., .false., & .true., .false., .true., .false. / data mask4 / .true., .false., .true., .false., & .true., .false., .true., .false., .true., & .false., .true., .false., .true., .false., & .true., .false. / print *, '-test 1---' print *, iall(ia2, 2, mask2) print *, '-test 2---' print *, iall(ia3, 2, mask3) print *, '-test 3---' print *, iall(ia4, 2, mask4) end --- With gfortran I got wrong result: -test 1--- 0 0 -test 2--- 0 0 0 0 -test 3--- 0 0 0 0 0 0 0 0 The expected result(checked with ifort) should be: -test 1--- 1 -1 -test 2--- 1 -15 -1 -test 3--- 1 -15 -19 -1 13 -1
[Bug fortran/96859] Wrong answer with intrinsic merge_bits
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96859 --- Comment #4 from zhen...@compiler-dev.com --- (In reply to kargl from comment #2) > gfortran appears to be correct. Writing an actual program with your > examples, I have > > program foo >print '(I0,1X,I0)', & >& merge_bits(32767_2,o'1234567',32767_2), & >& ior(iand(32767_2,32767_2),iand(o'1234567',not(32767_2))) > >print '(I0,1X,I0)', & >& merge_bits(o'1234567',32767_2,o'1234567'), & >& > ior(iand(o'1234567',int(o'1234567',2)),iand(32767_2,not(int(o'1234567',2 > >print '(I0,1X,I0)', & >& merge_bits(32767_2,o'1234567',b'010101'), & >& ior(iand(32767_2,b'010101'),iand(o'1234567', not(int(b'010101',2 > >print '(I0,1X,I0)', & >& merge_bits(32767_2,o'1234567',z'12345678'), & >& ior(iand(32767_2,z'12345678'), iand(o'1234567',not(int( > z'12345678',2 > end program foo I compiled your code with gfortran-10, getting result: -1 -1 -1 -1 -18057 -18057 -129 -129 The right one should be: 32767 32767 32767 32767 14711 14711 32639 32639
[Bug fortran/96859] Wrong answer with intrinsic merge_bits
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96859 --- Comment #3 from zhen...@compiler-dev.com --- (In reply to Dominique d'Humieres from comment #1) > What results do you expect? merge_bits(32767_2, o'1234567', 32767_2) merge_bits(o'1234567', 32767_2, o'1234567') merge_bits(32767_2, o'1234567', b'010101') merge_bits(32767_2, o'1234567', z'12345678') The four corresponding results should be: 32767 32767 14711 32639 I checked the Fortran 2008 standard and confirmed the results with hand calculation.
[Bug fortran/96859] New: Wrong answer with intrinsic merge_bits
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96859 Bug ID: 96859 Summary: Wrong answer with intrinsic merge_bits Product: gcc Version: 10.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: zhen...@compiler-dev.com Target Milestone: --- wrong result with compiled code such as: merge_bits(32767_2, o'1234567', 32767_2) merge_bits(o'1234567', 32767_2, o'1234567') merge_bits(32767_2, o'1234567', b'010101') merge_bits(32767_2, o'1234567', z'12345678')