Warnings on hex constants [Mingw-w64/Cygwin]
Angelo Graziosi
angelo.graziosi@alice.it
Mon May 31 15:56:00 GMT 2010
Il 31/05/2010 17.10, Steve Kargl ha scritto:
> On Mon, May 31, 2010 at 03:17:13PM +0200, Angelo Graziosi wrote:
>> Il 31/05/2010 3.35, Steve Kargl ha scritto:
>>> On Mon, May 31, 2010 at 01:32:10AM +0200, Angelo Graziosi wrote:
>>>>
>>>> Now, If I use gfortran-4.3.4 from Cygwin packages or
>>>> gfortran-4.6-20100409 from [2], the warnings are *absent* (same command
>>>> line on same test case).
>>>>
>>>> So, should we expect them at this stage of GCC-4.6 development or what
>>>> else?
>>>>
>>>
>>> What else would you expect given that the F2003 standard states:
>>
>> I apologize if I do not know all details of the standard... If so stands
>> the things, out of curiosity, how should it be rewritten the test case I
>> have reported? It was copy/pasted from page 116 of
>> http://gcc.gnu.org/onlinedocs/gfortran.pdf.
>
> Well, my first choice is "Don't use BOZ".
>
> PROGRAM test_iand
> INTEGER :: a, b, c, d
> DATA a / Z'F' /, b / Z'3' /
> DATA c / 15 /, d / 3 /
> WRITE (*,'(4(I0,1X))') a, b, c, d
> END PROGRAM test_iand
>
> laptop:kargl[230] gfc4x -o z -Wall q.f90
> q.f90:3.34:
>
> DATA a / Z'F' /, b / Z'3' /
> 1
> Warning: Possible change of value in conversion from INTEGER(8) to INTEGER(4) at (1)
> q.f90:3.18:
>
> DATA a / Z'F' /, b / Z'3' /
> 1
> Warning: Possible change of value in conversion from INTEGER(8) to INTEGER(4) at (1)
> laptop:kargl[231] ./z
> 15 3 15 3
>
> If you insist on BOZ, then try
>
> PROGRAM test_iand
> INTEGER, SAVE :: a, b
> a = int(Z'F')
> b = int(Z'3')
> WRITE (*,*) IAND(a, b)
> END PROGRAM test_iand
>
> laptop:kargl[239] gfc4x -o z -Wall q.f90
> laptop:kargl[240] ./z
> 3
>
> laptop:kargl[243] gfc4x -o z -Wall -std=f95 q.f90
> q.f90:3.14:
>
> a = int(Z'F')
> 1
> Error: Fortran 2003: BOZ used outside a DATA statement at (1)
> q.f90:4.14:
>
> b = int(Z'3')
> 1
> Error: Fortran 2003: BOZ used outside a DATA statement at (1)
I think the right way is this:
PROGRAM test_iand
implicit none
WRITE (*,*) IAND(int(Z'F'), int(Z'3'))
END PROGRAM test_iand
or this:
PROGRAM test_iand
INTEGER :: a = int(Z'F'),b = int(Z'3')
WRITE(*,*) IAND(a,b)
END PROGRAM test_iand
Both compile with:
$ mingw32-gfortran -Wall [-std=f2003] test_iand.f90
Perhaps the above examples should substitute that at page 116 of the
cited manual (see above).
Ciao,
Angelo.
More information about the Fortran
mailing list