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

    <tr>
        <th>Summary</th>
        <td>
            flang Unsupported expression in static initializer: ptrtoint
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    Context: I am currently experimenting with using flang-new-17 to compile the Fortran code in https://github.com/esmf-org/esmf.

`flang-new-17 --version`:
```
Ubuntu flang-new version 17.0.0 (++20230624042319+ee2bf319bc05-1~exp1~20230624042420.1017)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-17/bin
```

Error:
```
LLVM ERROR: Unsupported expression in static initializer: ptrtoint (ptr @_QMesmf_logerrmodE.di.esmf_log.logtableindex to i64)
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /usr/lib/llvm-17/bin/flang-new -fc1 -triple i386-pc-linux-gnu -emit-obj -I ./src/Infrastructure/Util/src -I ./build_config/Linux.llvm.default -I ./src/Infrastructure -I ./src/Superstructure -I ./mod/modO/Linux.llvm.32.mpiuni.default -I ./src/include -D ESMF_NO_INTEGER_1_BYTE -D ESMF_NO_INTEGER_2_BYTE -D ESMF_VERSION_STRING_GIT=\"v8.4.2-1-gbfda84e133\" -D ESMF_MOAB=1 -D ESMF_LAPACK=1 -D ESMF_LAPACK_INTERNAL=1 -D ESMF_NO_ACC_SOFTWARE_STACK=1 -D ESMF_YAMLCPP=1 -D ESMF_YAML=1 -D ESMF_NO_PTHREADS -D ESMF_NO_OPENMP -D ESMF_NO_OPENACC -D ESMF_BOPT_O -D Sx86_64_32=1 -D ESMF_OS_Linux=1 -D ESMF_COMM=mpiuni -D ESMF_DIR=/workspace/field-compression/lite/pyodide/packages/libesmf/build/libesmf-8.4.2 -D ESMF_MPIUNI -fcolor-diagnostics -mrelocation-model pic -pic-level 2 -target-cpu i686 -O1 -o ./obj/objO/Linux.llvm.32.mpiuni.default/ESMF_LogErr.o -x f95-cpp-input ./src/Infrastructure/Util/src/ESMF_LogErr.F90
 #0 0x00007fbf14c13cc6 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0xcb6cc6)
 #1 0x00007fbf14c11e70 llvm::sys::RunSignalHandlers() (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0xcb4e70)
 #2 0x00007fbf14c1435b (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0xcb735b)
 #3 0x00007fbf13a3a520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007fbf13a8ea7c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x96a7c)
 #5 0x00007fbf13a3a476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x00007fbf13a207f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x00007fbf14b770d5 llvm::report_fatal_error(llvm::Twine const&, bool) (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0xc1a0d5)
 #8 0x00007fbf154b0bc9 (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0x1553bc9)
 #9 0x00007fbf154b0fed (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0x1553fed)
#10 0x00007fbf154b346a (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0x155646a)
#11 0x00007fbf154b0f5b (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0x1553f5b)
#12 0x00007fbf154b346a (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0x155646a)
#13 0x00007fbf154b0f5b (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0x1553f5b)
#14 0x00007fbf154b3243 (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0x1556243)
#15 0x00007fbf154b0e90 (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0x1553e90)
#16 0x00007fbf154a648c llvm::AsmPrinter::emitGlobalConstant(llvm::DataLayout const&, llvm::Constant const*, llvm::DenseMap<unsigned long, llvm::SmallVector<llvm::GlobalAlias const*, 1u>, llvm::DenseMapInfo<unsigned long, void>, llvm::detail::DenseMapPair<unsigned long, llvm::SmallVector<llvm::GlobalAlias const*, 1u>>>*) (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0x154948c)
#17 0x00007fbf154a5e40 llvm::AsmPrinter::emitGlobalVariable(llvm::GlobalVariable const*) (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0x1548e40)
#18 0x00007fbf154acc77 llvm::AsmPrinter::doFinalization(llvm::Module&) (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0x154fc77)
#19 0x00007fbf14d53d11 llvm::FPPassManager::doFinalization(llvm::Module&) (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0xdf6d11)
#20 0x00007fbf14d4e781 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/usr/lib/llvm-17/bin/../lib/libLLVM-17.so.1+0xdf1781)
#21 0x000056453316c302 Fortran::frontend::CodeGenAction::executeAction() (/usr/lib/llvm-17/bin/flang-new+0xbd6302)
#22 0x000056453315fa2c Fortran::frontend::FrontendAction::execute() (/usr/lib/llvm-17/bin/flang-new+0xbc9a2c)
#23 0x0000564533152c5e Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&) (/usr/lib/llvm-17/bin/flang-new+0xbbcc5e)
#24 0x0000564533162b1e Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (/usr/lib/llvm-17/bin/flang-new+0xbccb1e)
#25 0x00005645331517a6 fc1_main(llvm::ArrayRef<char const*>, char const*) (/usr/lib/llvm-17/bin/flang-new+0xbbb7a6)
#26 0x0000564533150094 main (/usr/lib/llvm-17/bin/flang-new+0xbba094)
#27 0x00007fbf13a21d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#28 0x00007fbf13a21e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#29 0x000056453314f325 _start (/usr/lib/llvm-17/bin/flang-new+0xbb9325)
flang-new: error: unable to execute command: Aborted
flang-new: error: flang frontend command failed due to signal (use -v to see invocation)
Ubuntu flang-new version 17.0.0 (++20230624042319+ee2bf319bc05-1~exp1~20230624042420.1017)
Target: i386-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-17/bin
flang-new: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
flang-new: note: diagnostic msg: /tmp/ESMF_LogErr-3b49f2
flang-new: note: diagnostic msg: /tmp/ESMF_LogErr-3b49f2.sh
flang-new: note: diagnostic msg: 

********************
```

/tmp/ESMF_LogErr-3b49f2: [ESMF_LogErr-3b49f2.txt](https://github.com/llvm/llvm-project/files/11868412/ESMF_LogErr-3b49f2.txt)

/tmp/ESMF_LogErr-3b49f2.sh:
```
# Crash reproducer for Ubuntu clang version 17.0.0 (++20230624042319+ee2bf319bc05-1~exp1~20230624042420.1017)
# Driver args: "-c" "-O" "-fPIC" "-m32" "-ffree-line-length-none" "-I" "./src/Infrastructure/Util/src" "-I" "./build_config/Linux.llvm.default" "-I" "./src/Infrastructure" "-I" "./src/Superstructure" "-I" "./mod/modO/Linux.llvm.32.mpiuni.default" "-I" "./src/include" "-D" "ESMF_NO_INTEGER_1_BYTE" "-D" "ESMF_NO_INTEGER_2_BYTE" "-D" "ESMF_VERSION_STRING_GIT=\"v8.4.2-1-gbfda84e133\"" "-D" "ESMF_MOAB=1" "-D" "ESMF_LAPACK=1" "-D" "ESMF_LAPACK_INTERNAL=1" "-D" "ESMF_NO_ACC_SOFTWARE_STACK=1" "-D" "ESMF_YAMLCPP=1" "-D" "ESMF_YAML=1" "-D" "ESMF_NO_PTHREADS" "-D" "ESMF_NO_OPENMP" "-D" "ESMF_NO_OPENACC" "-D" "ESMF_BOPT_O" "-D" "Sx86_64_32=1" "-D" "ESMF_OS_Linux=1" "-D" "ESMF_COMM=mpiuni" "-D" "ESMF_DIR=/workspace/field-compression/lite/pyodide/packages/libesmf/build/libesmf-8.4.2" "-D" "ESMF_MPIUNI" "./src/Infrastructure/Util/src/ESMF_LogErr.F90" "-o" "./obj/objO/Linux.llvm.32.mpiuni.default/ESMF_LogErr.o"
# Original command:  "/usr/lib/llvm-17/bin/flang-new" "-fc1" "-triple" "i386-pc-linux-gnu" "-emit-obj" "-I" "./src/Infrastructure/Util/src" "-I" "./build_config/Linux.llvm.default" "-I" "./src/Infrastructure" "-I" "./src/Superstructure" "-I" "./mod/modO/Linux.llvm.32.mpiuni.default" "-I" "./src/include" "-D" "ESMF_NO_INTEGER_1_BYTE" "-D" "ESMF_NO_INTEGER_2_BYTE" "-D" "ESMF_VERSION_STRING_GIT=\"v8.4.2-1-gbfda84e133\"" "-D" "ESMF_MOAB=1" "-D" "ESMF_LAPACK=1" "-D" "ESMF_LAPACK_INTERNAL=1" "-D" "ESMF_NO_ACC_SOFTWARE_STACK=1" "-D" "ESMF_YAMLCPP=1" "-D" "ESMF_YAML=1" "-D" "ESMF_NO_PTHREADS" "-D" "ESMF_NO_OPENMP" "-D" "ESMF_NO_OPENACC" "-D" "ESMF_BOPT_O" "-D" "Sx86_64_32=1" "-D" "ESMF_OS_Linux=1" "-D" "ESMF_COMM=mpiuni" "-D" "ESMF_DIR=/workspace/field-compression/lite/pyodide/packages/libesmf/build/libesmf-8.4.2" "-D" "ESMF_MPIUNI" "-fcolor-diagnostics" "-mrelocation-model" "pic" "-pic-level" "2" "-target-cpu" "i686" "-O1" "-o" "./obj/objO/Linux.llvm.32.mpiuni.default/ESMF_LogErr.o" "-x" "f95-cpp-input" "./src/Infrastructure/Util/src/ESMF_LogErr.F90"
 "/usr/lib/llvm-17/bin/flang-new" "-fc1" "-triple" "i386-pc-linux-gnu" "-emit-obj" "-D" "ESMF_NO_INTEGER_1_BYTE" "-D" "ESMF_NO_INTEGER_2_BYTE" "-D" "ESMF_VERSION_STRING_GIT=\"v8.4.2-1-gbfda84e133\"" "-D" "ESMF_MOAB=1" "-D" "ESMF_LAPACK=1" "-D" "ESMF_LAPACK_INTERNAL=1" "-D" "ESMF_NO_ACC_SOFTWARE_STACK=1" "-D" "ESMF_YAMLCPP=1" "-D" "ESMF_YAML=1" "-D" "ESMF_NO_PTHREADS" "-D" "ESMF_NO_OPENMP" "-D" "ESMF_NO_OPENACC" "-D" "ESMF_BOPT_O" "-D" "Sx86_64_32=1" "-D" "ESMF_OS_Linux=1" "-D" "ESMF_COMM=mpiuni" "-D" "ESMF_DIR=/workspace/field-compression/lite/pyodide/packages/libesmf/build/libesmf-8.4.2" "-D" "ESMF_MPIUNI" "-fcolor-diagnostics" "-mrelocation-model" "pic" "-pic-level" "2" "-target-cpu" "i686" "-O1" "-x" "f95-cpp-input" "ESMF_LogErr-3b49f2"
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWktz4joW_jXORmXKlvxikQXhkaYmCQzQfeuuKFmWHXXbkkuW08ks7m-fkjAPEUKnc7k9i-lUijI68jnfeepxwE3DCk7ptRPeOOHoCrfqUcjrry1XL_IqFdnL9VBwRZ-VgwZgCnAFSCsl5ap8AfS5ppJVlCvGC_CdqUfQNvoxLzEvXE6_u34MlABEVDUrKVCPFEyEVBJzQERGAePgUam6cdDAgRMHTgqmHtu0R0TlwAltqtwVsugee443crxB9xl5lhTXfaKyYYI7kae5bSd1_-br57Tlqt2jA90rwI97Xs8DDkwceOPAG-hB5EUw8AKI_L4DbyiFaY78fkq80PX_os-1_9fBpAB6Pd_zYwf2N5JWWBbUmOw5idZR4NbELRlvn92Ct92UR0lxBiqR0VJPrEXDnjekKW8ULkuajZjUJAdO2kY6cFKyVH-WT5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