<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/58282>58282</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [flang] C types  int*fast_t specialized depending on target
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            flang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
            PeixinQiao
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          PeixinQiao
      </td>
    </tr>
</table>

<pre>
    ```
$ cat fortran_main016.f90 
! Test fortran call c for the scalar type and the scalar type is
! int_fast16_t with iso_c_binding
!
program main
  use iso_c_binding
  integer(C_INT_FAST16_T) :: my_x(2) = 1
  interface
    subroutine c_func(b)
      use iso_c_binding
      integer(C_INT_FAST16_T) :: b(2)
    end
  end interface
  call c_func(my_x)
end
$ cat c_func016.c 
#include<stdio.h>
#include<stdint.h>
void c_func_(int_fast16_t *a) {
  printf("%ld\n", a[0]);
  printf("%ld\n", a[1]);
}
$ cat fortran_main017.f90 
! Test fortran call c for the scalar type and the scalar type is
! int_fast32_t with iso_c_binding
!
program main
  use iso_c_binding
  integer(C_INT_FAST32_T) :: my_x(2) = 1
  interface
    subroutine c_func(b)
      use iso_c_binding
      integer(C_INT_FAST32_T) :: b(2)
    end
  end interface
  call c_func(my_x)
end
$ cat c_func017.c 
#include<stdio.h>
#include<stdint.h>
void c_func_(int_fast32_t *a) {
  printf("%ld\n", a[0]);
  printf("%ld\n", a[1]);
}
$ cat fortran_main019.f90 
! Test fortran call c for the scalar type and the scalar type is
! intmax_t with iso_c_binding
!
program main
  use iso_c_binding
  integer(C_INTMAX_T) :: my_x(2) = 1
  interface
    subroutine c_func(b)
      use iso_c_binding
      integer(C_INTMAX_T) :: b(2)
    end
  end interface
  call c_func(my_x)
end
$ cat c_func019.c 
#include<stdio.h>
#include<stdint.h>
void c_func_(intmax_t *a) {
  printf("%ld\n", a[0]);
  printf("%ld\n", a[1]);
}
```
```
$ cat run.sh 
for i in 016 017 019
do
echo "------- test $i ------."
echo "----- gfortran result:"
gcc c_func$i.c -c -o c-test.o
gfortran fortran_main$i.f90 -fno-range-check  -c -o fortran-test.o
gfortran c-test.o fortran-test.o
./a.out
rm *.o a.out
echo "----- flang-new result : "
clang c_func$i.c -c -o c-test.o
flang-new fortran_main$i.f90 -c -o fortran-test.o
flang-new -flang-experimental-exec c-test.o fortran-test.o
./a.out
rm *.o a.out
done
$ bash run.sh 
------- test 016 ------.
----- gfortran result:
1
1
----- flang-new result : 
65537
1
------- test 017 ------.
----- gfortran result:
1
1
----- flang-new result : 
4294967297
1
------- test 019 ------.
----- gfortran result:
1
1
----- flang-new result : 
1
0
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzNVkuPmzAQ_jVwsUC8CQcOadKVemjVqnvoDRl7ALfERNi0u_31HfMIm910W6nKdpERtuf1jeezTdnx-9xKvLl5e8vbWkFEGNWk6nrdU1kcqJCen7hV5pFFwye3oE4qqN62hJkh0Q0QhWOK3fsjECr5kzmhVj9C6qKiSvtJockPoRuUdgUrSiG5kPVJceoc-67u6YEYTNMMIYOCSzbEuIYaeivY7Ip3H26Lm-3nWwxzawUZscItNnK4L-5QHkxTe-I_tO0rymCZIEQNZd8NWkggrKgGydCwRMNV4xks5vkLPOUMZjUDyZcBdp_impZ-wTPlM5ufTJeKTmqmluxUyVBI1g4crHCnNBed21jh298IpX4g_d4JPnssMPJZHa1gS8es0jcLzmOPGhUqWgEmGLfcindy7O8IteI3nhXvDfLwry38RxZWun-OwOmVCRwGL0JgDPOqCPwIz8sQOL0igcc6vkYCZ9cj8IHeXZu877dfXg1xH2N5GdJm1yHtVLv_TNhHfxCXfyj6QbqqmdfAMFXgwhK8jvBN8Z0XkHfzQrKmw7wCZ3qINnxHX4JME65B9lST1Mue6EENrTY1XhRrxk5ViwTWw8HWEeYY3-4c92T_cPuN-mb_OZXsHJytwWENsG9k9jErX_a0BLiohXncUBf5PQ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