This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [gfortran] PATCH: Allow wide boz constants


Paul Brook wrote:
> No. Your patch breaks the following program. Beofre your patch it calle foo1, 
> after it calls foo2. Similar bad things could happen with implicit 
> interfaces.
> 
> program boz_type
>   interface foo
>     subroutine foo1(i)
>       integer i
>     end subroutine
>     subroutine foo2(i)
>       integer(kind=1) :: i
>     end subroutine
>   end interface
>   call foo(z'f')
> end program
> 
> There's also ambiguity when the sign bit is set. For example:
>   integer*8 i
>   i = z'0ffffffff'
> Should i be set to -1 or 4294967295? gfortran and g77 currently give different 
> answers for this.

Both examples are not conforming code, as boz-literal-constants are only
allowed as data initializers, so we could do whatever we want, and that's why
I didn't bother to preserve existing semantics in those cases. But I
understand that F2K allows boz constants everywhere, so I will look if that
standard offers a solution for these kinds of issues. I'll also see if that's
any different from what g77 does.

> How about using the smallest kind possible, but never smaller than the default 
> kind. Probably also add -Wlarge-boz-constant or similar.

If you think that's the right thing, and if F2K allows this, I will do this. I
had contemplated it, but was of the opinion that the user would specify the
bit width he wanted (even if that doesn't make much sense inside a data
statement).

- Tobi


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]