<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/177142>177142</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[flang] c_long_double support
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ivan-pi
</td>
</tr>
</table>
<pre>
For some reason flang allows the use of `c_long_double` in some contexts, but not in others:
```
program check_c_types
use, intrinsic :: iso_c_binding
implicit none
#if WITH_INTERFACE
interface
function strtold( str, endptr ) result(d) bind(C, name="strtold" )
!! <stdlib.h> :: long double strtold(const char *str, char **endptr)
import
character(kind=c_char,len=1),dimension(*),intent(in) :: str
type(c_ptr), intent(inout) :: endptr
real(c_long_double) :: d
end function strtold
end interface
#endif
print *, "--- Floating Point Type Properties ---"
print *
! Properties for C_LONG_DOUBLE
! Note: Some compilers/platforms may map this to the same as C_DOUBLE
print *, "Type: C_LONG_DOUBLE"
print *, " Precision (digits): ", precision(0.0_c_long_double)
print *, " Range (exponent): ", range(0.0_c_long_double)
print *, " Smallest Positive: ", tiny(0.0_c_long_double)
print *, " Largest Positive: ", huge(0.0_c_long_double)
print *, " Size in bytes: ", c_sizeof(0.0_c_long_double)
print *, " Kind value: ", c_long_double
end program check_c_types
```
```
$ flang check_c_types.F90 && ./a.out
--- Floating Point Type Properties ---
Type: C_LONG_DOUBLE
Precision (digits): 33
Range (exponent): 4931
Smallest Positive: 3.3621031431120935062626778173217526E-4932
Largest Positive: 1.189731495357231765085759326628007E+4932
Size in bytes: 16
Kind value: 16
```
```
$ flang -DWITH_INTERFACE check_c_types.F90 && ./a.out
error: Semantic errors in check_c_types.F90
./check_c_types.F90:12:13: error: REAL(KIND=16) is not an enabled type for this target
real(c_long_double) :: d
^^^^^^^^^^^^^^^^^^^^^^^
```
The issue surfaced when trying to compile json-fortran: https://github.com/jacobwilliams/json-fortran/issues/619
</pre>
<img width="1"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