------- Comment #3 from phl at kth dot se 2008-02-17 05:18 ------- Subject: Re: IBITS gives compiler error
> > > ------- Comment #2 from kargl at gcc dot gnu dot org 2008-02-17 01:08 > ------- > (In reply to comment #0) >> hades [TEST] cat bug-ibits.f90 >> program main >> write (*, *) ibits (-1, 0, bit_size (0)) >> end program main >> > > (snip) > > What result do you expect? In this case I expect a running program to print "-1". > >> Compiling with g95 works fine though. > > Appears g95 may have a bug. See Sec. 13.3, 13.4, and most importantly > 13.7 in the 'Final Committee Draft J3/03-007R2' of the Fortran 2003 > standard. In that case a lot of compilers have the same bug. :-) Appears more likely gfortran has a bug. Pasting from the f90-standard: "13.13.42 IBITS (I, POS, LEN) Description. Extracts a sequence of bits. Class. Elemental function. Arguments. I must be of type integer. POS must be of type integer. It must be nonnegative and POS + LEN must be less than or equal to BIT_SIZE (I). LEN must be of type integer and nonnegative. Result Type and Type Parameter. Same as I. Result Value. The result has the value of the sequence of LEN bits in I beginning at bit POS right- adjusted and with all other bits zero. The model for the interpretation of an integer value as a sequence of bits is in 13.5.7. Example. IBITS (14, 1, 3) has the value 7." To conclude, the error message is incorrect. Regards PHL -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35223