<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/121972>121972</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[flang] fatal internal error: CHECK(IsValidKindOfIntrinsicType(category_, kind_)) failed in flang/include/flang/Evaluate/type.h
</td>
</tr>
<tr>
<th>Labels</th>
<td>
flang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
yype
</td>
</tr>
</table>
<pre>
Hi there, flang crashes from an assertion failure on the following test case:
```fortran
module acc_declare_test
integer(16), parameter :: ifCondition = .FALSE.
real, dimension(n) :: data1
end module
```
Tested version(s): 19.1.0, trunk.
Example: https://godbolt.org/z/7jnEjP55s
Stack dump:
<details>
<summary>Click me</summary>
```
fatal internal error: CHECK(IsValidKindOfIntrinsicType(category_, kind_)) failed at /root/llvm-project/flang/include/flang/Evaluate/type.h(98)
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-llvmflang-trunk-20250107/bin/flang -fc1 -triple x86_64-unknown-linux-gnu -S -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu x86-64 -mllvm -x86-asm-syntax=intel -resource-dir /opt/compiler-explorer/clang-llvmflang-trunk-20250107/lib/clang/20 -mframe-pointer=all -o /app/output.s -x f95-cpp-input /app/example.f90
#0 0x00000000039ffa18 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-llvmflang-trunk-20250107/bin/flang+0x39ffa18)
#1 0x00000000039fd5dc SignalHandler(int) Signals.cpp:0:0
#2 0x00007e13ce042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#3 0x00007e13ce0969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#4 0x00007e13ce042476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#5 0x00007e13ce0287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#6 0x00000000053ed959 (/opt/compiler-explorer/clang-llvmflang-trunk-20250107/bin/flang+0x53ed959)
#7 0x000000000500be33 Fortran::evaluate::DataConstantConversionExtension(Fortran::evaluate::FoldingContext&, Fortran::evaluate::DynamicType const&, Fortran::evaluate::Expr<Fortran::evaluate::SomeType> const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20250107/bin/flang+0x500be33)
#8 0x0000000004a1c973 Fortran::evaluate::NonPointerInitializationExpr(Fortran::semantics::Symbol const&, Fortran::evaluate::Expr<Fortran::evaluate::SomeType>&&, Fortran::evaluate::FoldingContext&, Fortran::semantics::Scope const*) (/opt/compiler-explorer/clang-llvmflang-trunk-20250107/bin/flang+0x4a1c973)
#9 0x000000000447a096 std::optional<Fortran::evaluate::Expr<Fortran::evaluate::SomeType>> Fortran::semantics::BaseVisitor::EvaluateNonPointerInitializer<Fortran::parser::Constant<Fortran::common::Indirection<Fortran::parser::Expr, false>>>(Fortran::semantics::Symbol const&, Fortran::parser::Constant<Fortran::common::Indirection<Fortran::parser::Expr, false>> const&, Fortran::parser::CharBlock) (/opt/compiler-explorer/clang-llvmflang-trunk-20250107/bin/flang+0x447a096)
#10 0x000000000447a2bd Fortran::semantics::DeclarationVisitor::NonPointerInitialization(Fortran::parser::Name const&, Fortran::parser::Constant<Fortran::common::Indirection<Fortran::parser::Expr, false>> const&) (.part.0) resolve-names.cpp:0:0
#11 0x000000000448bd26 Fortran::semantics::DeclarationVisitor::Initialization(Fortran::parser::Name const&, Fortran::parser::Initialization const&, bool) (/opt/compiler-explorer/clang-llvmflang-trunk-20250107/bin/flang+0x448bd26)
#12 0x000000000448d723 Fortran::semantics::DeclarationVisitor::Post(Fortran::parser::EntityDecl const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20250107/bin/flang+0x448d723)
#13 0x000000000449de68 void Fortran::parser::detail::ParseTreeVisitorLookupScope::Walk<Fortran::parser::DeclarationConstruct, Fortran::semantics::ResolveNamesVisitor>(std::__cxx11::list<Fortran::parser::DeclarationConstruct, std::allocator<Fortran::parser::DeclarationConstruct>> const&, Fortran::semantics::ResolveNamesVisitor&) (/opt/compiler-explorer/clang-llvmflang-trunk-20250107/bin/flang+0x449de68)
#14 0x000000000449ad9d Fortran::semantics::ResolveNamesVisitor::Pre(Fortran::parser::SpecificationPart const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20250107/bin/flang+0x449ad9d)
#15 0x00000000044da207 Fortran::semantics::ResolveNamesVisitor::ResolveSpecificationParts(Fortran::semantics::ProgramTree&) (.part.0) resolve-names.cpp:0:0
#16 0x00000000044da9b1 Fortran::semantics::ResolveNamesVisitor::Pre(Fortran::parser::ProgramUnit const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20250107/bin/flang+0x44da9b1)
#17 0x00000000044dbe0c Fortran::semantics::ResolveNames(Fortran::semantics::SemanticsContext&, Fortran::parser::Program const&, Fortran::semantics::Scope&) (/opt/compiler-explorer/clang-llvmflang-trunk-20250107/bin/flang+0x44dbe0c)
#18 0x0000000004541f4e Fortran::semantics::Semantics::Perform() (/opt/compiler-explorer/clang-llvmflang-trunk-20250107/bin/flang+0x4541f4e)
#19 0x0000000003a537bd Fortran::frontend::FrontendAction::runSemanticChecks() (/opt/compiler-explorer/clang-llvmflang-trunk-20250107/bin/flang+0x3a537bd)
#20 0x0000000003de1932 Fortran::frontend::CodeGenAction::beginSourceFileAction() (/opt/compiler-explorer/clang-llvmflang-trunk-20250107/bin/flang+0x3de1932)
#21 0x0000000003a51f8d Fortran::frontend::FrontendAction::beginSourceFile(Fortran::frontend::CompilerInstance&, Fortran::frontend::FrontendInputFile const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20250107/bin/flang+0x3a51f8d)
#22 0x0000000003a42c27 Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&) (/opt/compiler-explorer/clang-llvmflang-trunk-20250107/bin/flang+0x3a42c27)
#23 0x0000000003a59c03 Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (/opt/compiler-explorer/clang-llvmflang-trunk-20250107/bin/flang+0x3a59c03)
#24 0x0000000001f7cd27 fc1_main(llvm::ArrayRef<char const*>, char const*) (/opt/compiler-explorer/clang-llvmflang-trunk-20250107/bin/flang+0x1f7cd27)
#25 0x0000000001e5068e main (/opt/compiler-explorer/clang-llvmflang-trunk-20250107/bin/flang+0x1e5068e)
#26 0x00007e13ce029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#27 0x00007e13ce029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#28 0x0000000001f7b795 _start (/opt/compiler-explorer/clang-llvmflang-trunk-20250107/bin/flang+0x1f7b795)
flang-20: error: unable to execute command: Aborted (core dumped)
flang-20: error: flang frontend command failed due to signal (use -v to see invocation)
flang version 20.0.0git (https://github.com/llvm/llvm-project.git 97097958fdf525e8c14fcdde94231bae72ea2673)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-llvmflang-trunk-20250107/bin
flang-20: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
flang-20: note: diagnostic msg: /tmp/example-c3742d
flang-20: note: diagnostic msg: /tmp/example-c3742d.sh
flang-20: note: diagnostic msg:
********************
Compiler returned: 254
```
</details>
The test case was generated by a fuzzer.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzEWt9u27jTfRrlhpAhUbIlXeTCdextsMU2aLK7lwZFjmw2FCmQVGr36T-QkiNbTZ2kXX-_IgUihTM8c-bw74gYwzcS4DqYfgimN1ektVulr_f7Bq5KxfbXHzmyW9AQ4AWqBJEbRDUxWzCo0qpGRCJiDGjLlUQV4aLVgJR0NqhSQqhvXG6QBWMRJQaCZB5E_mcWdT-V0lYTGUTzWrFWACKUrhlQQTSsnV0QzRGXFjagA5zHswAXDktDNKnBgkb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