https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118499

--- Comment #16 from kargls at comcast dot net ---
On 1/17/25 03:47, tkoenig at gcc dot gnu.org wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118499
> 
> --- Comment #15 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
> (In reply to kargls from comment #14)
>> (In reply to anlauf from comment #13)
>>> (In reply to kargls from comment #12)
>>>> (In reply to Thomas Koenig from comment #9)
>>>>> Question is, what should we permit...
>>>>>
>>>>> For 'normal' operations, only unsigned op unsigned is permitted,
>>>>> so unsigned**unsigned is obviously ok.
>>>>>
>>>>> What about (integer|real|complex)**unsigned?
>>>>>
>>>>> What about unsigned**integer?
>>>>>
>>>>> Since exponentiation is special (and also does not involve
>>>>> type conversion) my feeling is to allow it all.
>>>>>
>>>>> Comments?
>>>>
>>>> Agree with the others.  Supporting the above is fine.
>>>> What about allowing unsigned**(real|complex)? The Fortran standard
>>>> allows integer**(real|complex).
>>>
>>> I would vote against this.  Mathematically, the result cannot be an
>>> unsigned.
>>
>> As I noted, the standard allows integer**(real|complex).
>>
>> % cat a.f90
>> program foo
>>     integer u
>>     real x
>>     complex c
>>     x = 1.25
>>     u = 2
>>     c = (1.25,3.14)
>>     print *, u**x, u**c
>> end program
>> % gfcx -o z -std=f2018 a.f90 && ./z
>>     2.37841415                (-1.35409331,1.95532227)
>>
>> The result is not integer.  It literally is the expected
>> mathematical expression exp((real|complex)*log(unsigned))
> 
> Do I understand correctly that the integer argument is promoted
> to real first? This would be the sort of implicit conversion that
> is generally excluded from UNSIGNED.
> 

F2023 does not explicitly state a conversion occurs.
There is Table 10.2 on page 161.  This shows the types
of the operands and the results of **.  I'll need to look
at the J3 text again, but if 'unsigned+(real|integer|complex)'
is only allowed with explicit conversion of the 'unsigned'
to the type of operand 2, then exponentiation would also
require explicit conversion.

Reply via email to