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

    <tr>
        <th>Summary</th>
        <td>
            [flang] Runtime problem of printing `c_ptr`?
        </td>
    </tr>

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

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

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

<pre>
    ```
$ cat a.f90 
program main
  use iso_c_binding
  type(c_ptr) :: ptr
  integer, target :: i = 10
  ptr = c_loc(i)
  print *, "Fortran data = ", i
  print *, "Fortran address = ", ptr
  call c_print_addr(i)
end

$ cat b.c 
#include <stdio.h>

void c_print_addr_(int **p) {
  printf("C data = %d\n", *p);
  printf("C Address = %d\n", p);
}

$ cat run.sh 
#!/bin/bash

echo && echo "---------flang-new---------"
flang-new a.f90 -c
clang b.c -c -w
flang-new -flang-experimental-exec a.o b.o
./a.out

echo && echo "---------gfortran---------"
gfortran a.f90 -c
gcc b.c -c -w
gfortran a.o b.o
./a.out

$ bash run.sh 

---------flang-new---------
 Fortran data =  10
 Fortran address =  94052642349520
C data = 10
C Address = 1448501712

---------gfortran---------
 Fortran data =           10
 Fortran address =               4210784
C data = 10
C Address = 4210784
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyNVMuyoyAQ_RrcULEURePCRW4yWc_MD6QIoDJlJAV4H38_jY9Ec58UpdLd53C6bThr8VaiLJpmdEDRDpEUc-YwC6siwqPtanRt2AVfmOpGC8a9lVhZfeKns-qE6urZ4d6uEpEtP12dQaTAKNnBxH41RajOyVqCc48dM7V0c4yCjwOOozkQMIOFn1rNgVMB381ngAYjsvM0iJCjNs6wDgvm2AACm3ep7wBMCCOtXWIWWjlrW9h_AJ986EqG7MRUtVXtziHHsyVRHW97IYF_b51QOmxQ8muJetZKrLY4-T1mrbvrUMT8aZVHBSEgdr9MlwpE992UwgREySe43SrrFXSFQ_nhowxN34W2uSeJSIzIETrBP5ltlhjJGw17ZDDx9E0286ha1tWbTr7cLF7FgLu5pl7c8NHOvX2o8Qbmy2PwRClfr9Koi-wca2EhObBoQOkxPgShYOjdj5XW1dgw74XOngedNeePKheR32nxlfaVfCj18PyqeuPffnca7qfqo77HRRpRkqUkSQtKpshFc8U307Jv4jTd0ijOY_KhuPcF-0zbbXwtcjVSEkf5Nv2h1FX07cYLZBlnGSFxFudZIMpEFEnBAqdcK0tEn4byInrAf_vOQS_BGdLnVl6wrsbjBNceBp7xrgPK5Bj0pi0b567W32nkCLNWrumhEfQFFm37PL82wPZPcgdLZW0vLXzQnKZJ0JRFTrYZT1hGeExEksuUkERCCjTlZ0bToGVn2VovEtpw1JnszCjTNyY9BKokESFRESXwowjNwoLRrNiKalulpKJCoDSScKW3oVcTalMHphyEnfvagrNV1tm7k1mr6k4OlfH8rHeNNuVvqV5V90cxHQxplEMO_wGE_78-">