| Issue |
177142
|
| Summary |
[flang] c_long_double support
|
| Labels |
|
| Assignees |
|
| Reporter |
ivan-pi
|
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
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs