------- Comment #6 from dominiq at lps dot ens dot fr  2008-02-17 13:10 -------
I dont want to rant again about gfortran feature, but nevertheless I'll repeat
that this error should not be the default behavior (even a warning will an
overkill that should be restricted to -std=f* -pedantic).

Now I think the gfortran behavior is inconsistent with this respect. The
following code

print *, not(0), iand(-1,-1)!, ibits (-1, 0, bit_size (0))
print *, ibset(2147483647, bit_size(0)-1)
end

compiles silently and the executable prints:

          -1          -1
          -1

Why 2**32-1 should give an error as the result of ibits(-1, 0, bit_size (0))
and -1 as the result of ibset(2147483647, bit_size(0)-1)?

Looking at the f2003 standard (just before 13.4), I read:

Effectively, this model defines an integer object to consist of z bits in
sequence numbered from right to left from 0 to z − 1. This model is valid
only in the context of the use of such an object as the argument or result of
one of the bit manipulation procedures. In all other contexts, the model
defined for an integer in 13.4 applies. In particular, whereas the models are
identical for w_{z−1} = 0, they do not correspond for w_{z−1} = 1
and the interpretation of bits in such objects is processor dependent.

As usual, the last sentence shows the infinite wisdom of  the committee, but
does not say that w_{z−1} = 1 is forbidden, nor that the "processor"
should throw an error. According my understanding of the "least surprise
effect", I think gfortran should follow the other compilers and consider that
outside the "bit pattern" context, w_{z−1} = 1 corresponds to "s=-1" in
the integer model defined in 13.4.


-- 


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

Reply via email to